Created
August 3, 2018 16:48
-
-
Save iamshreeram/366231ce59c53df06af82f3655a2605d to your computer and use it in GitHub Desktop.
Restarting every HP VTS ports installed in Windows Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $NODE='C:\Program Files\HP\VTS\web\node.exe' | |
| $VTSCMD='C:\Program Files\HP\VTS\web\vtscmd' | |
| $LISTCOMD='/list' | |
| $STARTCOMD='/start' | |
| $STOPCOMD='/stop_all' | |
| # Writing all port details to file | |
| & $NODE $VTSCMD $LISTCOMD |% { If ($_ -match "^.+?name: (?<Name>.+?)\s+port: (?<Port>.+?)$") { Write-Output "$('{0},{1}' -f $matches['Name'], $matches['Port'])"}} | Out-File -Append 'ports.csv' -Encoding UTF8 | |
| # Stop all ports | |
| & $NODE $VTSCMD $STOPCOMD | |
| # Import the port from file and start every ports | |
| Import-Csv .\ports.csv -Header Name,Port | Foreach-Object { | |
| & $NODE $VTSCMD $STARTCOMD /name $_.Name /port $_.Port | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment