Hello,
I'm new in the powershell world. we are using v1.0 and i'm trying to check if a folder exists on a server or not.
this is what I have for the moment
$folderPath = 'D$AdminScriptsGSK_AutoUpdate'#'D$AdminScriptsGSK_AutoUpdate'
$Serverlist = Import-Csv D:powershellSKB_NTS_SERVERS.csv
foreach($DeviceName in $Serverlist )
{
echo $DeviceName
if((Test-path -Path \'$DeviceName'$folderPath) -eq $FALSE)
{
Write-Host \$DeviceNameD$AdminScriptsGSK_AutoUpdate
Write-Host $DeviceName"The folder does not exist."
}
else
{
Write-Host $DeviceName"The folder exists."
}
}
but it doesn't work and this is the result
DeviceName
———-
WAVSAWN095
\@{DeviceName=WAVSAWN095}D$AdminScriptsGSK_AutoUpdate
@{DeviceName=WAVSAWN095}The folder does not exist.
WAVSXBAK01
\@{DeviceName=WAVSXBAK01}D$AdminScriptsGSK_AutoUpdate
@{DeviceName=WAVSXBAK01}The folder does not exist.
rixsawn11302
\@{DeviceName=rixsawn11302}D$AdminScriptsGSK_AutoUpdate
@{DeviceName=rixsawn11302}The folder does not exist.
wavsawn10402
\@{DeviceName=wavsawn10402}D$AdminScriptsGSK_AutoUpdate
@{DeviceName=wavsawn10402}The folder does not exist.
saesdwn032
\@{DeviceName=saesdwn032}D$AdminScriptsGSK_AutoUpdate
@{DeviceName=saesdwn032}The folder does not exist.
how can i remove @{DeviceName=saesdwn032} in the path as this seems to be my problem
Regards