I want to remove the single quotes at the beginning and end like desired output. And I want to enclose this part “C:WindowsSystem32wusa.exe” in double quotes. How can I do that ?
Here is my script :
$Paths = Get-ChildItem -Path "C:KBUPDATE2016" | Select-Object -ExpandProperty Name
$counter = 0
Write-Host "!!! Run below commands on Windows Server 2016 machines"
foreach($path in $Paths){
$logfilename = "wusa" + $counter
Write-Host "'Start-Process -FilePath "C:WindowsSystem32wusa.exe" -ArgumentList 'C:KBUPDATE2016$path /quiet /norestart /Log:C:KBUPDATE2016$($logfilename).log' -Wait'"
$counter ++
}
My output :
!!! Run below commands on Windows Server 2016 machines
'Start-Process -FilePath C:WindowsSystem32wusa.exe -ArgumentList 'C:KBUPDATE2016windows10.0-kb5036609-x64-ndp48_087fa1e62da956ae7e7fc0f994321e00a59cf1cf.ms
u /quiet /norestart /Log:C:KBUPDATE2016wusa0.log' -Wait'
'Start-Process -FilePath C:WindowsSystem32wusa.exe -ArgumentList 'C:KBUPDATE2016windows10.0-kb5036899-x64_55391ef83ffb9a029d2489da756a3fb562d4e600.msu /qui
et /norestart /Log:C:KBUPDATE2016wusa1.log' -Wait'
'Start-Process -FilePath C:WindowsSystem32wusa.exe -ArgumentList 'C:KBUPDATE2016windows10.0-kb5037016-x64_dde96790d66ed77a63239fd5a8e69db88c626029.msu /qui
et /norestart /Log:C:KBUPDATE2016wusa2.log' -Wait'
My Desired Output :
!!! Run below commands on Windows Server 2016 machines
Start-Process -FilePath "C:WindowsSystem32wusa.exe" -ArgumentList 'C:KBUPDATE2016windows10.0-kb5036609-x64-ndp48_087fa1e62da956ae7e7fc0f994321e00a59cf1cf.ms
u /quiet /norestart /Log:C:KBUPDATE2016wusa0.log' -Wait
Start-Process -FilePath "C:WindowsSystem32wusa.exe" -ArgumentList 'C:KBUPDATE2016windows10.0-kb5036899-x64_55391ef83ffb9a029d2489da756a3fb562d4e600.msu /qui
et /norestart /Log:C:KBUPDATE2016wusa1.log' -Wait
Start-Process -FilePath "C:WindowsSystem32wusa.exe" -ArgumentList 'C:KBUPDATE2016windows10.0-kb5037016-x64_dde96790d66ed77a63239fd5a8e69db88c626029.msu /qui
et /norestart /Log:C:KBUPDATE2016wusa2.log' -Wait