I’m a newbie in powershell & trying to do a script for my work. I’ve gotten some things working but some how it’s not fully functioning. I’ll need some pointers… Thanks in advance.
Check the folder exist or not? Then pop out messasge.
Check the folder exist or not & edit folder name? Then pop out messasge.
Check inside config/text file if a string of specific special words Like example “d:\apps\report\Logs\log-%” exist or not? Then pop out messasge.
Check inside config/text file if a string of specific special words exist or not then edit it to something else. Like example “d:\apps\report\Logs\log-%” to become “d:\apps/record\Log\logs-%”. Then pop out messasge.
#1 & 2)Tested Successful - Have Pop Up!
$Folder = ‘C:\Testings’
“Test to see if folder [$Folder] exists”
if (Test-Path -Path $Folder) {
[System.Windows.MessageBox]::Show(‘Path exists!’)
} else {
[System.Windows.MessageBox]::Show(‘Path do not exist!’)
}
IMHO that’s not a good idea. In the vast majority of the cases I want a script to make its job and not bother me with some messages. I’d only use user interactions when there are decissions to make you cannot automate.
You can provide a file directly to Select-Object. No need to pipe it.
Show what you have and explain where you get stuck.
You can use
to get the files content and
to iterate over each indicvidual line. For each individual line you check if it’s what you expect - you already know how this works. And if there is the desired pattern you use a -replace to replace the text you want
Please always read the help topics for the cmdlets you’re about to use completely including the examples to learn how to use them.
And BTW: When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.