Don is filming the Powershell mini series at the moment. I thought it would be a great idea for people to chuck up any PowerShell commands they have written/found that might help general server administrators.
I will go first.
To show the scope usage regarding number of used and free ip addreses for all scopes on a DHCP server run:
Get-DhcpServerv4ScopeStatistics -ComputerName dc
Powershell - Cheats & Tips For Server Administrators
How did you view the results after running the Get command? I looked online and saw references to Receive-Job; however, I could not figure it out.
If you run this from a PowerShell window the results should be shown on the screen. You will need to run the command on the server that has the DHCP role configured (or open a remote PowerShell session to the server)
Below is a remote session that I have just done: (If you are connected to the server already you don't need to do the first line)
PS C:\Users\mikep> Enter-PsSession -ComputerName dc.contoso.local -Credential contoso\administrator
[dc]: PS C:\Users\Administrator\Documents>Get-DhcpServerv4ScopeStatistics -ComputerName dc
ScopeId Free InUse PercentageInUse Reserved Pending SuperscopeName ------- ---- ----- --------------- -------- ------- -------------- 192.168.1.0 68 19 21.83908 14 0
Hope this helps!
Also tips/tricks for PowerShell. A few weeks ago I was able to install PowerShell 5.0 (as a piece of the larger Windows Management Framework 5.0 Preview) on my WinBook TW700 (1Gb of RAM, 16Mb of flash drive storage). The system even crashed (where I lost the Downloads folder stored on a micro-SD card) and I had to restore it, with PowerShell 5.0 still working.
However, my WinBook TW801 (double the RAM and flash storage, at 2Gb and 32Gb respectively) continually has a panning bar with "Preparing the installation" when running the same download (November 2014 online, which shouldn't be any different than what I grabbed for the TW700). Both have the same "Windows 8.1 with Bing" OS, although I applied most of the updates beforehand (lessons learned) for the TW801. In looking over the requirements, Microsoft lists only Windows 8.1 Pro and Enterprise.
So did I somehow slip under the wire to get PS 5 on the TW700?....
Huh, further updates: On both WinBooks, both "get-host" and "$PSVersionTable.PSVersion" tell me I have version 4! I thought version 4 couldn't run on Windows 8/8.1, and Powershell 2.0 is marked in the "Windows Features" screen. Maybe Windows 8.1 with Bing is released with PS4.0, and I either don't remember the PS5.0 installation on the TW700 correctly, or it was lost with the crash.
I also intended to provide an update that PowerShell reports the same version data, but on the TW801 the copyright date is displayed as 2013, the TW700 displays a 2014 copyright...
Of the current "consumer" grades of Windows, these are the maximum versions of Powershell you can install on those systems:
Windows 8.1 Pro+: Powershell 5.0
Windows 8.1 with Bing: Powershell 4.0
Windows 7: Powershell 4.0
EoL (End-of-Life) Windows Vista and Windows XP can run Powershell 2.0 maximum
Anyone who is interested in learning more should watch the videos in the course library. They are perfect for getting a grounding on PowerShell. Once you learn it you will never look back
Just a thought from a sysadmin in the field. CIM related commandlets are going to become very popular soon with Microsoft deciding to deprecate SNMP and only support up to version v2c. With no SNMPv3 support, which is starting to be pushed by compliance organizations such as PCI DSS and the like, Microsoft's only alternative currently is this.
SNMP is deprecated. Instead, use the Common Information Model (CIM), which is supported by the WS-Management web services protocol and implemented as Windows Remote Management.
I believe you kind of touched on it if I'm remembering rightly from when I watched the powershell courses you had but perhaps it would be a good one to go back and do something as a standalone/add-on for that material? Yes, you could always just use Get-Help but this is a large and complex class of commandlets. Save for those of us with a ton of time (ha, does that even happen in the IT world?) diving into that is kind of complex. If nothing else at least a running start into CIM might be helpful for those like me that work in industries that require it.