#create variables for file names used in move
$hideFile = "app_offline.off.htm"
$liveFile = "app_offline.htm"
#create an array of directories you want to swap files in
$path = @(
"C:\InetPub\Site1"
,"C:\InetPub\Site2"
,"C:\InetPub\Site3"
)
#counters for while loop based on number of directories
#NOTE: Count enumerates from 1. array position enumerates from 0
$maxCnt = $path.Count
$currCnt = 0
#create a log
$logFile = "\temp.txt"
Set-Variable -name log -value $env:userprofile$logFile
if (Test-Path $log) {rm $log}
New-Item $log -type file
#set-variable was used to construct the path due to errors I was getting calling the path and file variables on the fly
#NOTE: Count enumerates from 1. array position enumerates from 0
while ($currCnt -lt $maxCnt)
{
Set-Variable -name currPath -value $path[$currCnt.ToString()]
; Set-Variable -name hidePath -value $currPath$hideFile
; Set-Variable -name livePath -value $currPath$liveFile
; Set-Variable -name currTime -value (Get-Date)
; Move-Item $hidePath $livePath >> $log
; echo "$currTime moved $hidePath to $livePath" >> $log
; $currCnt = $currCnt +1
}
$hideFile = "app_offline.off.htm"
$liveFile = "app_offline.htm"
#create an array of directories you want to swap files in
$path = @(
"C:\InetPub\Site1"
,"C:\InetPub\Site2"
,"C:\InetPub\Site3"
)
#counters for while loop based on number of directories
#NOTE: Count enumerates from 1. array position enumerates from 0
$maxCnt = $path.Count
$currCnt = 0
#create a log
$logFile = "\temp.txt"
Set-Variable -name log -value $env:userprofile$logFile
if (Test-Path $log) {rm $log}
New-Item $log -type file
#set-variable was used to construct the path due to errors I was getting calling the path and file variables on the fly
#NOTE: Count enumerates from 1. array position enumerates from 0
while ($currCnt -lt $maxCnt)
{
Set-Variable -name currPath -value $path[$currCnt.ToString()]
; Set-Variable -name hidePath -value $currPath$hideFile
; Set-Variable -name livePath -value $currPath$liveFile
; Set-Variable -name currTime -value (Get-Date)
; Move-Item $hidePath $livePath >> $log
; echo "$currTime moved $hidePath to $livePath" >> $log
; $currCnt = $currCnt +1
}
No comments:
Post a Comment