Skip to content

Instantly share code, notes, and snippets.

@vMarkusK
Created April 29, 2016 12:32
Show Gist options
  • Save vMarkusK/3a1fb2e9d51e9cad5037bf494c85f104 to your computer and use it in GitHub Desktop.
Save vMarkusK/3a1fb2e9d51e9cad5037bf494c85f104 to your computer and use it in GitHub Desktop.
$DAPs = @("DAP01.lan.local","DAP02.lan.local") #MediaSever
$DPCs = @("DPC01.lan.local") #Cell Server
$TempPath = "D:\OmniBackData\tmp" #Path to DP Temp Files
foreach ($DAP in $DAPs) {
Write-Output "Testing $DAP..."
if (Test-WsMan $DAP) {
Write-Output "Processing $DAP..."
Invoke-Command -ComputerName $DAP -ScriptBlock {Get-Service -Name omniInet | Stop-Service}
Invoke-Command -ComputerName $DAP -ScriptBlock {Get-ChildItem $TempPath | Remove-Item -Confirm:$False -Recurse}
Invoke-Command -ComputerName $DAP -ScriptBlock {Get-Service -Name omniInet | Start-Service}
Write-Output "Completed $DAP"
}
else {
Write-Output "Failure while Processing $DAP via Remote-PowerShell"
}
}
foreach ($DPC in $DPCs) {
Write-Output "Testing $DPC..."
if (Test-WsMan $DPC) {
Write-Output "Processing $DPC..."
Invoke-Command -ComputerName $DPC -ScriptBlock {CMD.EXE /C omnisv stop}
Invoke-Command -ComputerName $DPC -ScriptBlock {Get-ChildItem $TempPath | Remove-Item -Confirm:$False -Recurse}
Invoke-Command -ComputerName $DPC -ScriptBlock {CMD.EXE /C omnisv start}
Write-Output "Completed $DPC"
}
else {
Write-Output "Failure while Processing $DPC via Remote-PowerShell"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment