Reputation: 59
Hi guys I am trying to write a script >>Newbie<< and I would like to run it through task scheduler. It is a windows server update service cleanup tool. I have run the commands individually, as running them altogether seems to not work on my server just the same as running the gui. I would like to run all procceses from the one script. After entering the command it prompts me for a -Port number, and I would like to run it silently.
Get-WsusServer "wus" | Invoke-WsusServerCleanup -CleanupObsoleteUpdates
After running this it will prompt me for a port number; which is 8530 I would like the script to enter it for me then go to the next command when complete; e.g.
Get-WsusServer "wus" | Invoke-WsusServerCleanup -CleanupUnneededContentFiles
Thanks in advance
Upvotes: 2
Views: 1453
Reputation: 2342
You could specify parameter names:
$WsusServer = Get-WsusServer -Name "wus" -Port 8530
$WsusServer | Invoke-WsusServerCleanup -CleanupObsoleteUpdates
$WsusServer | Invoke-WsusServerCleanup -CleanupUnneededContentFiles
Optionally, if you need to specify the command to use SSL:
$WsusServer = Get-WsusServer -Name "wus" -Port 8530 -UseSsl
$WsusServer | Invoke-WsusServerCleanup -CleanupObsoleteUpdates
$WsusServer | Invoke-WsusServerCleanup -CleanupUnneededContentFiles
Upvotes: 0
Reputation: 24525
The prompt appears because the -PortNumber
parameter is mandatory and you are not specifying it. To run the cmdlet without prompting for the parameter, specify it on the command line:
Get-WsusServer "wus" -PortNumber 8530
Upvotes: 2