Book Image

Windows Server 2016 Automation with PowerShell Cookbook - Second Edition

By : Thomas Lee, Ed Goad
Book Image

Windows Server 2016 Automation with PowerShell Cookbook - Second Edition

By: Thomas Lee, Ed Goad

Overview of this book

This book showcases several ways that Windows administrators can use to automate and streamline their job. You'll start with the PowerShell and Windows Server fundamentals, where you'll become well versed with PowerShell and Windows Server features. In the next module, Core Windows Server 2016, you'll implement Nano Server, manage Windows updates, and implement troubleshooting and server inventories. You'll then move on to the Networking module, where you'll manage Windows network services and network shares. The last module covers Azure and DSC, where you will use Azure on PowerShell and DSC to easily maintain Windows servers.
Table of Contents (21 chapters)
Title Page
Credits
About the Author
Acknowledgment
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Finding expired computers in AD


Expired computers, computers that have not logged on recently, can be something you need to investigate. A client computer that has not logged on to the domain for, say, a month, could have been stolen. Such a computer could also be an under-used asset that is a candidate for redeployment. If it's a server that has not logged in for a month, it could indicate a computer that is non-functioning and one you should investigate.

This recipe is a variation on the Report on AD Users recipe.

Getting ready

This recipe needs computer accounts in the AD.

How to do it...

  1. Build the report header:
$RKReport = ''$RkReport += "*** Reskit.Org AD Unused 
                      + "Computer Report`n"$RKReport += "*** Generated [$(Get-Date)]`n"$RKReport += "***********************************`n`n"
  1. Report on computer accounts that have not logged in in past 14 days:
$RkReport += "*** Machines not logged on in past 14 days`n"$FortnightAgo = (Get-Date).AddDays(-14)$RKReport += Get-ADComputer...