write output in text file for multiple scripts i.e system info

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Foxzyy
Posts: 1
Last visit: Thu Oct 20, 2016 12:34 pm

write output in text file for multiple scripts i.e system info

Post by Foxzyy »

  1. $path="$([Environment]::GetFolderPath("Desktop"))\info.txt";
  2.  
  3. gcim Win32_OperatingSystem | select Caption, InstallDate | fl > $path; notepad $path;
  4.  
  5. Write-Host "Drive information for $env:ComputerName"
  6.  
  7. Get-WmiObject -Class Win32_LogicalDisk |
  8.     Where-Object {$_.DriveType -ne 5} |
  9.     Sort-Object -Property Name |
  10.     Select-Object Name, VolumeName, VolumeSerialNumber,SerialNumber, FileSystem, Description, VolumeDirty, `
  11.         @{"Label"="DiskSize(GB)";"Expression"={"{0:N}" -f ($_.Size/1GB) -as [float]}}, `
  12.         @{"Label"="FreeSpace(GB)";"Expression"={"{0:N}" -f ($_.FreeSpace/1GB) -as [float]}}, `
  13.         @{"Label"="%Free";"Expression"={"{0:N}" -f ($_.FreeSpace/$_.Size*100) -as [float]}} |
  14.     Format-Table -AutoSize
I would like to have all such ouput of above script in info.txt.

Also need help in identifying members in Administrator group and produce that output as well in info.txt
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: write output in text file for multiple scripts i.e system info

Post by jvierra »

Just output all using the >> operator or use Out-File -append.
This topic is 7 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked