0
我的PowerShell命令是这样的:在批处理文件的问题调用Powershell的
Get-WmiObject -class Win32_printer | ft name, systemName, shareName >> $PSScriptRoot\printers.txt
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, InstallDate | Format-Table –AutoSize >> $PSScriptRoot\programs.txt
Get-WmiObject -Class Win32_MappedLogicalDisk | select Name, ProviderName >> $PSScriptRoot\drives.txt
我批的是:
@ECHO OFF
SET Directory=%~dp0
SET PowerShellScriptPath=%Directory%reimage_checklist.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%'";
如果我运行在IDE的PowerShell脚本,它提出了三个文本文件与请求的信息。如果我运行批处理文件,它会输出三个批处理文件,但网络驱动器文本文件是空白的。
感谢肯解决了,我不能弄清楚如何编辑它这样。 – giveen
删除'-NoProfile'参数,看看是否不能解决您的问题。很确定,它可以在不加载当前用户信息的情况下运行,包括其映射的驱动器。 – TheMadTechnician
@TheMadTechnician它应该忽略PowerShell配置文件吗? – Matt