Help with Conditional if then script
i new powershell. have written basic scripts use backup , restores of data local ftp server. first 4 lines of script follow. between lines 2 , 3 need conditional checks see if directory called \\192.168.0.1\backup\$name exists. if stops script running further , shows error saying directory exists. , if directory doesn't exist finish running rest of script. if can great.
echo "please make sure outlook closed before continuing"$name = read-host "enter customers email address"
new-item -path $("\\192.168.0.1\backup\"+$name+"\pstfiles") -itemtype directory -force
new-item -path $("\\192.168.0.1\backup\"+$name+"\cdrive") -itemtype directory -force
you need use test-path see if directory exists.
test-path returns $true or $false result..
if(test-path 'my path' -eq $true){<code execute if condition true>}
inspired heineken.
Windows Server > Windows PowerShell
Comments
Post a Comment