I am currently using a script to pull information from monitors such as Manufacturer, Model, and Serial Number. At the moment the script exports the file to a folder that has already been created. I am needing to modify the script so it can automatically create the folder and file.
Script:
$Monitors = Get-WmiObject WmiMonitorID -Namespace rootwmi
$LogFile = "C:estmonitors.txt"
function Decode {
if ($args[0] -is [System.Array]){
[System.Text.Encoding]::ASCII.GetString($args[0])
}
Else {
"Not Found"
}
}
echo "Manufacturer", "Name", "Serial Number"
ForEach ($Monitor in $Monitors) {
$Manufacturer = Decode $Monitor.ManufacturerName -nomatch 0
$Name = Decode $Monitor.UserFriendlyName -nomatch 0
$Serial = Decode $Monitor.SerialNumberID -nomatch 0
echo "$Manufacturer, $Name, $Serial" >> $LogFile
}
question from:
https://stackoverflow.com/questions/65852834/need-to-output-the-results-of-a-powershell-script 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…