Powershell 将文件从映射的驱动器复制到用户本地"Z:" "C:"



您好,我希望我的powershell脚本能够从映射驱动器(Z:(复制文件并将其复制到域"C:/temp/"文件夹中的用户。目前,我的脚本如下所示。

$Computer = Read-Host -Prompt 'Enter the Computer Name you are accessing'

########## Install Software On PC ##########
New-Item -ItemType directory -Path "\$Computerc$tempopenVPN"
Copy-Item "Z:(15) ITVPNopenvpn-install-2.4.8-I602-Win7.exe" "\$Computerc$temp" -Recurse
Copy-Item "Z:(15) ITVPNoffice.opvn" "\$Computerc$temp" -Recurse

Write-Host "Installing openVPN on $Computer"
Invoke-Command -ComputerName $Computer -ScriptBlock {Start-Process "c:tempopenVPNopenvpn-install-2.4.8-I602-Win7.exe" -ArgumentList "/q" -Wait} 
Invoke-Command -ComputerName $Computer -ScriptBlock {Start-Process "c:tempopenVPNopenvpn-install-2.4.8-I602-Win7.exe" -ArgumentList "/q" -Wait} 

但是,我收到错误

复制项目:找不到驱动器。名称为"Z"的驱动器不存在。

将不胜感激任何帮助!

由于某种原因,您的会话看不到 Z 驱动器。

如果可以,请断开 Z 驱动器的连接。 然后,在访问 Z 驱动器之前,使用 New-PSDrive PowerShell 命令在同一会话中映射驱动器。

New-PSDrive –Name "Z" –PSProvider FileSystem –Root "\servernamepath" –Persist

此外,请尝试在标准模式和"以管理员身份运行"模式下运行PowerShell。

最新更新