是否使用PowerShell 2.0在客户端中遍历目录并打印文件?
使用Powershell 2.0,是否可以在客户端安装的打印机上遍历目录并打印文件 我得到了下面的PowerShell脚本。它在共享网络驱动器上工作得很好,但我如何实际修改并使用它来查询WebDav文件夹的内容,然后在客户端(而不是服务器端)仅打印.PDF文件扩展名 用于遍历目录的PowerShell脚本:是否使用PowerShell 2.0在客户端中遍历目录并打印文件?,powershell,webdav,Powershell,Webdav,使用Powershell 2.0,是否可以在客户端安装的打印机上遍历目录并打印文件 我得到了下面的PowerShell脚本。它在共享网络驱动器上工作得很好,但我如何实际修改并使用它来查询WebDav文件夹的内容,然后在客户端(而不是服务器端)仅打印.PDF文件扩展名 用于遍历目录的PowerShell脚本: function print-file($file) { begin { function internal-printfile($thefile) {
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
下面的命令应该完成这个任务-遍历目录中的所有文件,获取它们的内容并将内容发送到当前打印机。我对它进行了测试,效果很好:
Get-ChildItem . -filter *.* -recurse | get-content | out-printer
它获取当前文件夹中的所有文件。是,它适用于已映射到Windows资源管理器的普通目录。下面是我用来遍历目录的另一个脚本:此脚本还将返回子目录,听起来与问题所要查找的不一样