A podcast about Windows PowerShell.
In this show I discussed the cmdlets Get-Command, Get-Help and Get-Member.
Here is a great video discussion of these cmdlets by Jeffrey Snover.
I also talked about a great Technet video by Don Jones about the PowerShell Pipeline.
For our first PowerShell moment I talked about $f= dir
The one-liner (full version) is:
Get-Content servers.txt | %{$x = net time \\$_; $x[0];If($x[2].contains(”Local”)){$x[2]}} | Add-Content Servertime.txt
You can find more detail about this one-liner in an earlier post.
I am enjoying playing catch-up and have made it through episodes 0 & 1. I have been looking at the get-help and get-member cmdlets, but have so far not found one thing I want to have as a “one-liner” – a command line that will return the free space on a certain drive. What I want to do is create a script that will go and get the free space on critical server drives, and save said information into a text file. I can then schedule the script to run, then have notepad open it for me for my perusal when I get in each morning.
Hi Bill,
I can see why you are having an issue with this one. It seems like one of the existing cmdlets would be able to give you the free disk space, but if so I was not able to find it. I had to use the get-wmiobject cmdlet to get the info from WMI. Here’s a quick one-liner to get you started.
gc servers.txt | ForEach-Object{get-wmiobject -computername $_ win32_logicaldisk | select-object systemname, deviceID, Freespace;”`n”} | Export-Csv serverdata.csv
This bit “`n” will put a space between each server in your output file which you may or may not want.
Thanks for listening!
Jonathan
Hey Jonathon –
Just getting my feet wet in powershell and came across your podcast from another blog I follow on codebetter.com. So I am starting wayyy back at episode zero and just finished this one.
I am sure the format has changed since this one, but I like it so far and hope to become an expert soon by following your podcast and following up on resources that you recommend throughout the podcast.
Question though … where are the show notes and links that you mentioned in this podcast? Particularly the technet videos by Don Jones?
Thanks
strike that question … just actually RTFA. my fault!
First link (Jeffrey Snover) no longer works