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

Popular posts from this blog

some help on Event 540

WMI Repository 4GB limit - Win 2003 Ent Question

Event ID 1302 (error 1307) DFS replication service encountered an error while writing to the debug log file