2
#VARIABLES
$Source = Read-host "Please provide DIR location you wish to copy its contents from.
ie. (UNC, Absolute paths, etc)"
$Serverlist = Read-Host "Please provide the location of the server list. (UNC, Absolute
paths, etc)"
$Servers = Get-Content -Path $Serverlist
#$Destination1 = \\$Server\c$\inetpub\wwwroot\'
#$Destination2 = \\$Server\c$\wmpub\wmroot\'
#EXECUTION
$Servers | foreach-object {
Copy-Item -Path $Source*.wsx -Destination $Server\c$\inetpub\wwwroot\ -
force
Copy-Item -Path $Source*.nsc -Destination $Server\c$\wmpub\wmroot\ -force
}
#EVENTVWR LOGGING
$EventLog = New-Object System.Diagnostics.EventLog('Application')
$EventLog.MachineName = "."
$EventLog.Source = "Streaming Media Engineering"
$EventLog.WriteEntry('Copy Successful',"Information", 200)
#VIEWING OVERLOADS
($myevent.WriteEntry).OverloadDefinitions
Add-Type -AssemblyName System.Speech
$synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$synthesizer.Speak('Files have been moved over successfully...')
我似乎無法得到腳本來讀取$服務器變量出$目的地1和$嘗試執行Copy-Item循環時的Destination2路徑。請幫忙花了幾天的時間...爲什麼不能Powershell複製項目來源定製到一個UNC路徑被稱爲變量見下面
您收到的錯誤消息是什麼? – alroc 2012-08-12 11:23:21
基本上沒有錯誤,但沒有預期的結果。 – user1592499 2012-08-23 17:21:39
您的服務器列表在每個服務器之前包含\\,對嗎?你可以嘗試'Copy-Item -Path $ Source *。* -filter * .wsx -Destination $ Server \ c $ \ inetpub \ wwwroot \ -Force'並查看它是否有所作爲?那麼'Copy-Item -Path(join-path $ Source * .wsx)-Destination $ Server \ c $ \ inetpub \ wwwroot \ -Force'呢? – Joost 2013-03-29 13:52:21