Skip to content

Instantly share code, notes, and snippets.

@iamshreeram
Created August 3, 2018 16:48
Show Gist options
  • Save iamshreeram/366231ce59c53df06af82f3655a2605d to your computer and use it in GitHub Desktop.
Save iamshreeram/366231ce59c53df06af82f3655a2605d to your computer and use it in GitHub Desktop.
Restarting every HP VTS ports installed in Windows Server
$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