背景:应用安装文件经常需要拷贝到多台Windows 2012服务器,已共享文件夹
代码示例:
$spath = "\\ip\Setup" $dpath = "\\ip\Setup" $net = New-Object -com WScript.Network #映射网络驱动器 $net.MapNetworkDrive("M:", $spath, $true, "user", "password") $net.MapNetworkDrive("N:", $dpath, $true, "user", "password") #拷贝文件目录 Copy-Item M:\TFS N:\TFS -Recurse #断开映射 $net.RemoveNetworkDrive("M:",$true,$true) $net.RemoveNetworkDrive("N:",$true,$true)
原文:http://www.cnblogs.com/abelard/p/4840425.html