From 8be6d8f70a91cf97743c773c8fa7d416b2930011 Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Mon, 22 Mar 2021 17:58:34 +0000 Subject: [PATCH 01/15] 1st draft Ping Servers post --- Posts/2021/04/get-live-servers.md | 159 ++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 Posts/2021/04/get-live-servers.md diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md new file mode 100644 index 0000000..c58dfed --- /dev/null +++ b/Posts/2021/04/get-live-servers.md @@ -0,0 +1,159 @@ +--- +post_title: Testing The Connection to Computers in the Active Directory +username: tfl@psp.co.uk +Catagories: PowerShell +tags: Active Directory, networking +Summary: How can I get AD computers check to see they are online? +--- + +**Q:** As an administrator, I often have to do a lot of reporting on the servers in my domain. +Is there a simple way to test the connection to every server in my domain or to hosts in a specific OU? + +**A:** Of course you can do this with PowerShell, using the Active Directory cmdlets and `Test-Connection`. although it is not as simple as one might like. + +## Using the `ActiveDirectory` module + +Microsoft has developed several modules to help you deploy and manage AD in your organisation or via Azure. +The `ActiveDirectory` module is one which Microsoft ships with Windows Server (although not installed by default). +You can also load the Remote Server Administration (RSAT) module for AD on a Windows 10 host. +The RSAT module allows you to manage the AD using PowerShell from a remote machine. +For more details on the `ActiveDirectory` module, see the [ActiveDirectory module documentation](https://docs.microsoft.com/powershell/module/addsadministration/().) + +You can use the `Get-ADComputer` account to return details about some or all computers within the AD. +You have several ways to use `Get-ADComputer` to get just the computer accounts you want with any property you need. +These include using the **-Identity** and **-Filter** parameters. +Every computer account returned by `Get-ADComputer` contains two key properties: **Name** and **DNSHostName**. +The **Name** property is the single-label name of the computer (aka the NetBIOS name). +The **DNSHostName** property if the fully qualified DNS name for the computer. +Like this: + +```powershell-console +PS C:\Foo> Get-ADComputer -Filter * | Format-Table -Property Name, DNSHostName + +Name DNSHostName +---- ----------- +COOKHAM1 Cookham1.cookham.net +win10lt Win10LT.cookham.net +cookham24 cookham24.cookham.net +SLTPC sltpc.cookham.net +COOKHAM4LTDC Cookham4LTDC.cookham.net +``` + +So you might be tempted to think it simple to test connections to each computer. +You pipe the output of `Get-ADComputer` to `Test-Connection`, and it just works. +Sadly, it's not quite so simple: + +```powershell-console +PS C:\Foo> Get-ADComputer -Filter * | Test-Connection +Test-Connection: Cannot validate argument on parameter 'TargetName'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. +Test-Connection: Cannot validate argument on parameter 'TargetName'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. +Test-Connection: Cannot validate argument on parameter 'TargetName'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. +Test-Connection: Cannot validate argument on parameter 'TargetName'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. +Test-Connection: Cannot validate argument on parameter 'TargetName'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. +``` + +What is going on here? + +## Property/Parameter misalignment + +What we have here is a classic, albeit relatively uncommon, situation. +The `Test-Connection` cmdlet uses the parameter name **Target** to indicate the computer you are testing a connection with. +However, in this pipelined command, the objects produced by `Get-ADComputer` do not contain properties of that name. +Instead. these objects have properties named **Name** and **DNSHostName**. + +Please note: with Windows PowerShell, you used the parameter ComputerName to indicate the computer you are investigating. +With PowerShell 7, the developers have changed this parameter name `TargetName`. +For best compatibility, the cmdlet defines the `ComputerName` alias to this parameter. +This means you can use either **-TargetName** or **-Computername** with `Test-Connection`. + +## ForEach-Object to the rescue + +It is pretty easy to get around this parameter/property alignment challenge. +You use the `Foreach-Object` cmdlet, like this: + +```powershell-console +PS C:\Foo> Get-ADComputer -Filter * | + ForEach-Object {"$_";Test-Connection -TargetName $_.Name;""} + +CN=COOKHAM1,OU=Domain Controllers,DC=cookham,DC=net + Destination: COOKHAM1 +Ping Source Address Latency BufferSize Status + (ms) (B) +---- ------ ------- ------- ---------- ------ + 1 cookham24 10.10.10.9 0 32 Success + 2 cookham24 10.10.10.9 0 32 Success + 3 cookham24 10.10.10.9 0 32 Success + 4 cookham24 10.10.10.9 0 32 Success + +CN=win10lt,OU=CookhamHQ,DC=cookham,DC=net + Destination: win10lt +Ping Source Address Latency BufferSize Status + (ms) (B) +---- ------ ------- ------- ---------- ------ + 1 cookham24 * 0 32 DestinationHost… + 2 cookham24 * 0 32 DestinationHost… + 3 cookham24 * 0 32 DestinationHost… + 4 cookham24 * 0 32 DestinationHost… + +CN=SLTPC,CN=Computers,DC=cookham,DC=net + Destination: SLTPC +Ping Source Address Latency BufferSize Status + (ms) (B) +|---- ------ ------- ------- ---------- ------ + 1 cookham24 2a02:8010:6386:0:f810:2b… 1 32 Success + 2 cookham24 2a02:8010:6386:0:f810:2b… 0 32 Success + 3 cookham24 2a02:8010:6386:0:f810:2b… 0 32 Success + 4 cookham24 2a02:8010:6386:0:f810:2b… 3 32 Success +etc +``` + +## Using the Extensible Type System + +If you plan to do a lot of this sort of work, there is a simpler way to get around this alignment issue. +You can use the Extensible Type System (ETS) to extend any AD Computer object to contain an alias to the `Name` or `DNSHostName` property. +You define this extension via a small XML file which you then import, like this: + +```powershell-console +PS C:\Foo> get-content '.\aaatypes.types.ps1xml' + + + Microsoft.ActiveDirectory.Management.ADComputer + + + TargetName + DNSHostName + + + + + + +PS C:\Foo> Update-TypeData -PrependPath .\aaatypes.types.ps1xml +PS C:\Foo> Get-ADComputer -Identity Cookham1 | Test-Connection + + Destination: Cookham1.cookham.net + +Ping Source Address Latency BufferSize Status + (ms) (B) +---- ------ ------- ------- ---------- ------ + 1 cookham24 10.10.10.9 0 32 Success + 2 cookham24 10.10.10.9 0 32 Success + 3 cookham24 10.10.10.9 0 32 Success + 4 cookham24 10.10.10.9 0 32 Success +``` + +You can persist this ETS extension by adding the `Update-TypeData` to your PowerShell profile. +That way, every time you start a PowerShell session, that ETS extension is in place and ready to assist you. + +For details of and background to the ETS, see the [Extended Type System Overview](https://docs.microsoft.com/powershell/scripting/developer/ets/overview). + +## Summary + +The `Get-ADComputer` cmdlet produces objects whose properties are not aligned, pipeline wise, with Test-Connection. +There is a simple way around that, using `For-EachObject`, although it takes a bit more typing. +You can also use the ETS to extend the ADComputer object to have a more friendly alias. + +## Tip of the Hat + +This article was based on a request in this blog's issue queue +See the post [Request - How to get all the alive servers in the domain?](https://github.com/PowerShell/Community-Blog/issues/21). From b32b2c2ee4d4406a9cf263ed2c349ec94a7ef99d Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Wed, 24 Mar 2021 16:16:04 +0000 Subject: [PATCH 02/15] update get-live-server --- Posts/2021/04/get-live-servers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index c58dfed..ca2e08a 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -9,7 +9,7 @@ Summary: How can I get AD computers check to see they are online? **Q:** As an administrator, I often have to do a lot of reporting on the servers in my domain. Is there a simple way to test the connection to every server in my domain or to hosts in a specific OU? -**A:** Of course you can do this with PowerShell, using the Active Directory cmdlets and `Test-Connection`. although it is not as simple as one might like. +**A:** Of course you can do this with PowerShell, using the Active Directory cmdlets and `Test-Connection`, although it is not as simple as one might like. ## Using the `ActiveDirectory` module From ce3f70ce8625b6021098e3e927f85357fe1d9e83 Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 11:41:12 +0000 Subject: [PATCH 03/15] new post - get live servers --- Posts/2021/04/get-live-servers.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index ca2e08a..1b9e9f6 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -7,9 +7,9 @@ Summary: How can I get AD computers check to see they are online? --- **Q:** As an administrator, I often have to do a lot of reporting on the servers in my domain. -Is there a simple way to test the connection to every server in my domain or to hosts in a specific OU? +Is there a simple way to test the connection to every server in my domain or every server or client host in a specific OU? -**A:** Of course you can do this with PowerShell, using the Active Directory cmdlets and `Test-Connection`, although it is not as simple as one might like. +**A:** Of course you can do this with PowerShell! You can use the Active Directory cmdlets and `Test-Connection`, although it is not as simple as one might like. ## Using the `ActiveDirectory` module @@ -22,9 +22,9 @@ For more details on the `ActiveDirectory` module, see the [ActiveDirectory modul You can use the `Get-ADComputer` account to return details about some or all computers within the AD. You have several ways to use `Get-ADComputer` to get just the computer accounts you want with any property you need. These include using the **-Identity** and **-Filter** parameters. -Every computer account returned by `Get-ADComputer` contains two key properties: **Name** and **DNSHostName**. +Every computer account returned by `Get-ADComputer` contains two important properties: **Name** and **DNSHostName**. The **Name** property is the single-label name of the computer (aka the NetBIOS name). -The **DNSHostName** property if the fully qualified DNS name for the computer. +The **DNSHostName** property is the fully qualified DNS name for the computer. Like this: ```powershell-console @@ -41,7 +41,9 @@ COOKHAM4LTDC Cookham4LTDC.cookham.net So you might be tempted to think it simple to test connections to each computer. You pipe the output of `Get-ADComputer` to `Test-Connection`, and it just works. -Sadly, it's not quite so simple: +Sadly, it's not quite so simple. + +If you try this, here is what you would see: ```powershell-console PS C:\Foo> Get-ADComputer -Filter * | Test-Connection @@ -57,14 +59,14 @@ What is going on here? ## Property/Parameter misalignment What we have here is a classic, albeit relatively uncommon, situation. -The `Test-Connection` cmdlet uses the parameter name **Target** to indicate the computer you are testing a connection with. +The `Test-Connection` cmdlet uses the parameter name **Target** to indicate the computer to which you are testing a connection. However, in this pipelined command, the objects produced by `Get-ADComputer` do not contain properties of that name. -Instead. these objects have properties named **Name** and **DNSHostName**. +Instead, these objects have properties named **Name** and **DNSHostName**. Please note: with Windows PowerShell, you used the parameter ComputerName to indicate the computer you are investigating. With PowerShell 7, the developers have changed this parameter name `TargetName`. For best compatibility, the cmdlet defines the `ComputerName` alias to this parameter. -This means you can use either **-TargetName** or **-Computername** with `Test-Connection`. +This cmdlet lets you use either **-TargetName** or **-Computername** with `Test-Connection`. ## ForEach-Object to the rescue @@ -109,7 +111,7 @@ etc ## Using the Extensible Type System -If you plan to do a lot of this sort of work, there is a simpler way to get around this alignment issue. +If you plan to do a lot of this sort of work, there is a more straightforward way to get around this property/parameter alignment issue. You can use the Extensible Type System (ETS) to extend any AD Computer object to contain an alias to the `Name` or `DNSHostName` property. You define this extension via a small XML file which you then import, like this: @@ -149,11 +151,11 @@ For details of and background to the ETS, see the [Extended Type System Overview ## Summary -The `Get-ADComputer` cmdlet produces objects whose properties are not aligned, pipeline wise, with Test-Connection. +The `Get-ADComputer` cmdlet produces objects whose properties the object developers have not aligned, pipeline wise, with Test-Connection. There is a simple way around that, using `For-EachObject`, although it takes a bit more typing. -You can also use the ETS to extend the ADComputer object to have a more friendly alias. +You can also use the ETS to extend the `ADComputer` object to have a more friendly alias. ## Tip of the Hat This article was based on a request in this blog's issue queue -See the post [Request - How to get all the alive servers in the domain?](https://github.com/PowerShell/Community-Blog/issues/21). +See the post [Request - How to get all the alive servers in the domain?](https://github.com/PowerShell/Community-Blog/issues/21) From 7fcb9172916fd9912b5d4c9aa1a7ffc091e2e445 Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:42:17 +0000 Subject: [PATCH 04/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 1b9e9f6..d991848 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -1,5 +1,5 @@ --- -post_title: Testing The Connection to Computers in the Active Directory +post_title: Testing the connection to computers in the Active Directory username: tfl@psp.co.uk Catagories: PowerShell tags: Active Directory, networking From ab37dc673a1473338f11b301ff751e2f80df56c0 Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:42:37 +0000 Subject: [PATCH 05/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index d991848..064c472 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -17,7 +17,7 @@ Microsoft has developed several modules to help you deploy and manage AD in your The `ActiveDirectory` module is one which Microsoft ships with Windows Server (although not installed by default). You can also load the Remote Server Administration (RSAT) module for AD on a Windows 10 host. The RSAT module allows you to manage the AD using PowerShell from a remote machine. -For more details on the `ActiveDirectory` module, see the [ActiveDirectory module documentation](https://docs.microsoft.com/powershell/module/addsadministration/().) +For more details on the `ActiveDirectory` module, see the [ActiveDirectory](https://docs.microsoft.com/powershell/module/addsadministration/) module documentation. You can use the `Get-ADComputer` account to return details about some or all computers within the AD. You have several ways to use `Get-ADComputer` to get just the computer accounts you want with any property you need. From ce46cd52dbfbcf8cb7694aadab65cbd99688bce4 Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:43:10 +0000 Subject: [PATCH 06/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 064c472..6409a14 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -19,8 +19,8 @@ You can also load the Remote Server Administration (RSAT) module for AD on a Win The RSAT module allows you to manage the AD using PowerShell from a remote machine. For more details on the `ActiveDirectory` module, see the [ActiveDirectory](https://docs.microsoft.com/powershell/module/addsadministration/) module documentation. -You can use the `Get-ADComputer` account to return details about some or all computers within the AD. -You have several ways to use `Get-ADComputer` to get just the computer accounts you want with any property you need. +Use the `Get-ADComputer` account to return details about some or all computers within the AD. +There are several ways to use `Get-ADComputer` to get just the computer accounts you want with any property you need. These include using the **-Identity** and **-Filter** parameters. Every computer account returned by `Get-ADComputer` contains two important properties: **Name** and **DNSHostName**. The **Name** property is the single-label name of the computer (aka the NetBIOS name). From 906b896a040954cfd7f9548fc2d78d7e01e64eaa Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:43:33 +0000 Subject: [PATCH 07/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 6409a14..1df1c24 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -28,7 +28,7 @@ The **DNSHostName** property is the fully qualified DNS name for the computer. Like this: ```powershell-console -PS C:\Foo> Get-ADComputer -Filter * | Format-Table -Property Name, DNSHostName +PS> Get-ADComputer -Filter * | Format-Table -Property Name, DNSHostName Name DNSHostName ---- ----------- From 7404b5c6c320717567aea18b2aa3b5153851e9be Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:43:51 +0000 Subject: [PATCH 08/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 1df1c24..58ec37e 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -116,7 +116,7 @@ You can use the Extensible Type System (ETS) to extend any AD Computer object to You define this extension via a small XML file which you then import, like this: ```powershell-console -PS C:\Foo> get-content '.\aaatypes.types.ps1xml' +PS> Get-Content '.\aaatypes.types.ps1xml' Microsoft.ActiveDirectory.Management.ADComputer From 4cad626f4037860a1f10f2d5e58b08191f1ea1a1 Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:44:00 +0000 Subject: [PATCH 09/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 58ec37e..19648c7 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -130,8 +130,8 @@ PS> Get-Content '.\aaatypes.types.ps1xml' -PS C:\Foo> Update-TypeData -PrependPath .\aaatypes.types.ps1xml -PS C:\Foo> Get-ADComputer -Identity Cookham1 | Test-Connection +PS> Update-TypeData -PrependPath .\aaatypes.types.ps1xml +PS> Get-ADComputer -Identity Cookham1 | Test-Connection Destination: Cookham1.cookham.net From c4415592d5ff6a0eca8a3a71cf56d31a3dc56b1c Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:44:17 +0000 Subject: [PATCH 10/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 19648c7..537c113 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -151,7 +151,7 @@ For details of and background to the ETS, see the [Extended Type System Overview ## Summary -The `Get-ADComputer` cmdlet produces objects whose properties the object developers have not aligned, pipeline wise, with Test-Connection. +The `Get-ADComputer` cmdlet produces objects whose properties the object developers have not aligned, pipeline wise, with `Test-Connection`. There is a simple way around that, using `For-EachObject`, although it takes a bit more typing. You can also use the ETS to extend the `ADComputer` object to have a more friendly alias. From 872ea3a18451a3b932fad96952c67fd58dcdc9c7 Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:44:24 +0000 Subject: [PATCH 11/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 537c113..1cf77fa 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -153,7 +153,7 @@ For details of and background to the ETS, see the [Extended Type System Overview The `Get-ADComputer` cmdlet produces objects whose properties the object developers have not aligned, pipeline wise, with `Test-Connection`. There is a simple way around that, using `For-EachObject`, although it takes a bit more typing. -You can also use the ETS to extend the `ADComputer` object to have a more friendly alias. +You can also use the ETS to extend the **ADComputer** object to have a more friendly alias. ## Tip of the Hat From 48f14f839e675e7a0e67cdf4f0b91a7a16639027 Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:45:19 +0000 Subject: [PATCH 12/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 1cf77fa..27f07e3 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -21,7 +21,7 @@ For more details on the `ActiveDirectory` module, see the [ActiveDirectory](http Use the `Get-ADComputer` account to return details about some or all computers within the AD. There are several ways to use `Get-ADComputer` to get just the computer accounts you want with any property you need. -These include using the **-Identity** and **-Filter** parameters. +These include using the **Identity** and **Filter** parameters. Every computer account returned by `Get-ADComputer` contains two important properties: **Name** and **DNSHostName**. The **Name** property is the single-label name of the computer (aka the NetBIOS name). The **DNSHostName** property is the fully qualified DNS name for the computer. From 807fc292d5c2ed61b38bbd832b96d1444e4896d9 Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:45:34 +0000 Subject: [PATCH 13/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 27f07e3..2cd3c2d 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -74,7 +74,7 @@ It is pretty easy to get around this parameter/property alignment challenge. You use the `Foreach-Object` cmdlet, like this: ```powershell-console -PS C:\Foo> Get-ADComputer -Filter * | +PS> Get-ADComputer -Filter * | ForEach-Object {"$_";Test-Connection -TargetName $_.Name;""} CN=COOKHAM1,OU=Domain Controllers,DC=cookham,DC=net From 4491574166f7bc95ac8aa81ee2f5cdbbd0b3229b Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 15:45:56 +0000 Subject: [PATCH 14/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 2cd3c2d..5726585 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -46,7 +46,7 @@ Sadly, it's not quite so simple. If you try this, here is what you would see: ```powershell-console -PS C:\Foo> Get-ADComputer -Filter * | Test-Connection +PS> Get-ADComputer -Filter * | Test-Connection Test-Connection: Cannot validate argument on parameter 'TargetName'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. Test-Connection: Cannot validate argument on parameter 'TargetName'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. Test-Connection: Cannot validate argument on parameter 'TargetName'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. From a6308bfbaa579b0a47266902213f531b47eccd9b Mon Sep 17 00:00:00 2001 From: Thomas Lee Date: Thu, 25 Mar 2021 16:07:47 +0000 Subject: [PATCH 15/15] Update Posts/2021/04/get-live-servers.md Co-authored-by: Sean Wheeler --- Posts/2021/04/get-live-servers.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Posts/2021/04/get-live-servers.md b/Posts/2021/04/get-live-servers.md index 5726585..4ee5537 100644 --- a/Posts/2021/04/get-live-servers.md +++ b/Posts/2021/04/get-live-servers.md @@ -63,10 +63,10 @@ The `Test-Connection` cmdlet uses the parameter name **Target** to indicate the However, in this pipelined command, the objects produced by `Get-ADComputer` do not contain properties of that name. Instead, these objects have properties named **Name** and **DNSHostName**. -Please note: with Windows PowerShell, you used the parameter ComputerName to indicate the computer you are investigating. -With PowerShell 7, the developers have changed this parameter name `TargetName`. -For best compatibility, the cmdlet defines the `ComputerName` alias to this parameter. -This cmdlet lets you use either **-TargetName** or **-Computername** with `Test-Connection`. +[alert type="note" heading="Note"]With Windows PowerShell, you used the parameter **ComputerName** to indicate the computer you are investigating. +With PowerShell 7, the developers have changed this parameter name to **TargetName**. +For best compatibility, the cmdlet defines the**`ComputerName** alias to this parameter. +This cmdlet lets you use either **TargetName** or **Computername** with `Test-Connection`.[/alert] ## ForEach-Object to the rescue