3
使用Powershell 2.0,是否可以遍历客户端安装的打印机上的目录和打印文件?使用PowerShell 2.0遍历目录并在客户端打印文件?
我得到了下面的PowerShell脚本。它在共享网络驱动器上工作良好,但我如何实际修改并使用它来查询WebDav文件夹的内容,然后在客户端(而不是服务器端)仅打印.PDF文件扩展名?
PowerShell脚本遍历目录:
function print-file($file) {
begin {
function internal-printfile($thefile) {
if ($thefile -is [string]) {
$filename = $thefile
}
else {
if ($thefile.FullName -is [string]) {
$filename = $THEfile.FullName
}
}
$start = new-object System.Diagnostics.ProcessStartInfo $filename
$start.Verb = "print"
[System.Diagnostics.Process]::Start($start)
}
if ($file -ne $null) {
$filespecified = $true;
internal-printfile $file
}
}
process {
if (!$filespecified) {
write-Host process ; internal-printfile $_
}
}
}
dir *.pdf -r | print-file
是的,它适用于已经映射到Windows资源管理器的普通目录。 – 2010-10-08 06:43:43
感谢您的回复。 – 2010-10-08 06:43:58
这里是我用来遍历目录的另一个脚本: – 2010-10-11 00:13:41