Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft System Center Powershell Essentials

You're reading from   Microsoft System Center Powershell Essentials Efficiently administer, automate, and manage System Center environments using Windows PowerShell

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher Packt
ISBN-13 9781784397142
Length 140 pages
Edition 1st Edition
Arrow right icon
Toc

Table of Contents (10) Chapters Close

Preface 1. Setting up the Environment to Use PowerShell FREE CHAPTER 2. Administration of Configuration Manager through PowerShell 3. Scenario-based Scripting for SCCM Administration 4. Administration of Operations Manager through PowerShell 5. Scenario-based Scripting for SCOM Administration 6. Administration of Service Manager through PowerShell 7. Scenario-based Scripting for SCSM Administration 8. Best Practices Index

Scenario 6 – running a ping test


Before doing any automation on the list of computers, the most important aspect to be tested is whether the computer is reachable or not. If the computer is offline, there is no point in running any automation script block on the computer. Executing script blocks on offline computers will just increase the script execution time. So, it is always advised that you perform a ping test on the list of computers we get as input and run the block of automation script only on the computers that are reachable.

Sometimes, server administrators disable ping on the server. This code works only if the ping is not disabled at the firewall level.

Prescripting activities

The following code assumes that we have a complist.txt file in the D drive, which contains the list of all the computer names that are to be tested whether they are reachable or not:

$CompList = Get-Content -Path "D:\PowerShell\Complist.txt"
foreach ($Comp in $CompList)
{
  If (test-Connection -ComputerName...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image