我是新來的powershell。在什麼地方需要定義$ UNC以成功運行下列PowerShell程序?
$Source = "\\ahs-bind01\ftptest01\CRAR"
Get-ChildItem -Path $Source -recurse
$files = import-csv "C:\Users\us6205\Desktop\DatabaseNameConfigs\Test\CareMoveFileParentDestPaths.csv"
#loop to get values and store it
foreach ($UNC in $files)
{
$Path = Get-ChildItem -Path $UNC.path -recurse | Where-Object { ($_.PSIsContainer -eq $true) -and ($_.FullName -match "$Source") }
$Dest = $path | New-Item -path $path -itemtype directory | Move-Item -Path $Source -Destination $dest -Force
}
您是否嘗試運行腳本?它沒有成功運行?你有錯誤嗎?如果是這樣,它說什麼? –
我收到一個「New-Item:無法將參數綁定到參數Path,因爲它是空的。」關於如何解決這個問題的任何想法? – Peter
很可能是因爲'Get-ChildItem'語句產生空的結果。無論如何你想完成什麼?請退後一步,描述您嘗試解決的問題,而不是您認爲的解決方案。 –