The PowerShell community is vibrant, with many of its developers contributing new cmdlets and scripts to the open source PowerShell Core and creating PowerShell modules that automate data center processes and management.
Deploying Windows updates with code is never an easy task, but the PSWindowsUpdate module can help. This module enables you to view update installation history and pending updates, uninstall updates, install local updates and install updates remotely.
One of the especially useful cmdlets in PSWindowsUpdate is Get-WULastResults, which retrieves the last result of a Windows update search and installation status.
This article is part of
The Get-WUInstall cmdlet installs updates and can even filter for specific update categories and knowledge base (KB) updates. This example installs the KB4034658 update:
PoshWSUS is a module for managing the still-popular Windows Server Update Services. With this module, you can search updates installed on the WSUS server, approve or decline updates and change WSUS configurations.
There is a handy way to automate declining Windows preview updates. This example queries the WSUS server for any updates that contain the string "Preview of" that are not already declined and pipes that to Deny-PoshWSUSUpdate.
Another great task to automate with WSUS is to synchronize updates from Microsoft's servers to your internal WSUS server. You can accomplish this with the Start-PoshWSUSSync cmdlet:
PowerShell also enables you to easily combine cmdlets into scripts. You might, for example, sync WSUS and then set your system to decline any updates.
Carbon is a popular module -- and for good reason. It's a module created for many different tasks. Carbon interacts with users, websites, certificates, services, host files, file permissions and other areas in Windows.
One unique cmdlet is Get-CProgramInstallInfo, which is the equivalent of using Programs and Features in the Windows GUI.
The example below shows how to get information on a local Google Chrome installation. In this example, you can see useful information, such as the install date, language, installation source and uninstall string. Note the uninstall string is the command used to uninstall the software from the system.
Many applications require you to install the .NET Framework on a system. With Carbon, you can use the Test-CDotNet cmdlet to see if you've installed version 2 or version 4.
Though PowerShell has native support for working with NTFS file permissions, the NTFSSecurity module provides a more user-friendly and intuitive approach.
A common piece of information an IT administrator needs to know is the effective permission for a user on a file or folder. The effective permission is the result of group membership of a user, inherited permissions, nested groups and denied permissions.
Here is how the Get-NTFSEffectiveAccess cmdlet finds the effective permission of the local path c:\temp:
Another common task is setting ownership on a file or folder with NTFS. Here, the c:\temp folder is set to have "Dan" as the owner. Then, you can use Get-NTFSSOwner to display the current owner.
There are more than 3,000 modules in the PowerShell Gallery, and the PowerShell community continues to publish methods to use PowerShell for automation.
Chances are, if you need to interact with a data center system, there is a PowerShell module available. Installing community modules is as simple as using the Install-Module PowerShell cmdlet.