I want to output some information about devices to .txt file but something went wrong. Could someone tell me what the problem is?
$devices=("wsu1","wsu2")
$file="C:\reports\file.txt"
Invoke-Command -ComputerName $devices -ScriptBlock {
Get-WmiObject Win32_OperatingSystem |
Select PSComputerName, Caption, OSArchitecture, Version, BuildNumber | Out-File -FilePath $file
}
& explorer.exe "C:\reports\"
I retrieve this message from the console:
Cannot bind argument to parameter 'FilePath' because it is null.
+ CategoryInfo : InvalidData: (:) [Out-File], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.OutFileCommand
Select PSComputerName, Caption, OSArchitecture, Version, BuildNumber | Out-File -FilePath $using:file } & explorer.exe "C:\reports\" `Did I do that correctly? – Nick S Aug 26 '22 at 18:09