last day (15 days later) » 

4:17 PM
-1
Q: Understanding a PowerShell Script

nitinsh99I am new to PowerShell scripting. I have been given the task to understand what a PowerShell script is doing. I am stuck at following line: & $basePath\CPAU.exe -u $($sqlUser.UserName) -p $(ConvertTo-UnsecureString $sqlUser.Password) -ex "cmd /c (sqlcmd $($sqlArgs -join ' ') > $outputFile && ec...

 
-u username, -p password and -ex is probably execute?
 
Thanks, could you write an answer explaining whole line? I still don't get what is "||" for and TRUE>FAILURE?
Kindly give the down vote reason please.
 
I'm not very good at powershell, just pointed out some things. The || is an or condition.
 
No, or is written as "-OR" in powershell
 
I'm pretty sure that || still stands for an OR condition in this case.
 
4:18 PM
Hi, maybe you are right. Maybe it's not a powershell OR then
 
It is an or for the cmd session that is being run
 
Hmm..
how about
 
& = Execute the following string
 
if (!(Test-Path .\SUCCESS))
 
$basePath\CPAU.exe = the executeable to run
-u $($sqlUser.UserName) -p $(ConvertTo-UnsecureString $sqlUser.Password) -ex "cmd /c (sqlcmd $($sqlArgs -join ' ') > $outputFile && echo TRUE > SUCCESS) || echo TRUE > FAILURE" -wait -nowarn -hide
all of the rest of that are command line parameters for that executeable and don't have anything to do with powershell really
 
4:20 PM
still..TRUE>SUCCESS doesn't quite makes sense
also
if (!(Test-Path .\SUCCESS))
seems to be powershell?
 
in if (!(Test-Path .\SUCCESS)) the ! is the negation symbol. It is a holdover from PS v1 when -NOT did not exist
if (!(Test-Path .\SUCCESS)) is powershell, but that isn't in the question that you asked
 
I asked..
In above if statement, what does .\SUCCESS mean? Doesn't Test-Path operate on some sort of path to test whether it exists or not?
Test-Path is not operating not some sort of path?
 
TRUE>SUCCESS and .\SUCCESS are just examples of crappy naming
.\SUCCESS is a textfile that some output is being redirected to
 
ohhh..thank you so much...that explains it all
While we are the topic, could you please explain this last line
Remove-Item .\SUCCESS -Force > $null
specifically
Haaa..Thanks for the explanation.
 
It deletes the crappily named file at the end
| $null just forces any output from the command to not be shown
the output is being redirected to null
 

last day (15 days later) »