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