'Need to export the write output datas
I am wrote a script to get and the save the result to text file. But i cant able to save the data to excel file. I can able to get the what i can except. I want to save those datas to text file.
$user = (Get-WMIObject -ClassName Win32_ComputerSystem).Username
$hostn = $env:COMPUTERNAME
Write-Output "$user, $hostn"
Solution 1:[1]
I used pscustomobject. look a the script :)
$user = (Get-WMIObject -ClassName Win32_ComputerSystem).Username
$hostn = $env:COMPUTERNAME
$output =[pscustomobject]@{
'UserName' = $user
'computername' = $hostn
}
$output | Export-CSV c:\temp\usermanager.csv -Append -NoTypeInformation -Force
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tal Folkman |

