1 2 3 4 |
(Get-Help Get-ChildItem -Detailed).count (Get-Help Get-ChildItem -Detailed |Out-String -Stream).count 159 |
1 2 3 4 5 6 7 8 9 |
Get-Help Get-ChildItem -Detailed |Out-String -Stream |Select-String -Pattern "Cert" -SimpleMatch certificate store. Example 6: Get all certificates in a certification drive that have code-signing authority PS C:\>Get-ChildItem -Path "Cert:\*" -Recurse -CodeSigningCert This command gets all of the certificates in the Windows PowerShell Cert: drive that have... The first command imports the Microsoft.PowerShell.Security module into the session. This module includes the Cert... The second command uses the Get-ChildItem cmdlet. The value of the Path parameter is the Cert: drive. CodeSigningCertificate parameter is a... |
Wenn ich mehrere möglicher Suchwörter habe, dann erstelle ich eine kurze Stringliste
$pattern = "Cert","HKLM"
Get-Help Get-ChildItem -Detailed |Out-String -Stream |Select-String -Pattern $pattern -SimpleMatch
1 2 3 4 5 6 7 8 9 10 11 |
$pattern = "Cert","HKLM" Get-Help Get-ChildItem -Detailed |Out-String -Stream |Select-String -Pattern $pattern -SimpleMatch certificate store. PS C:\>Get-ChildItem -Path "HKLM:\Software" Example 6: Get all certificates in a certification drive that have code-signing authority PS C:\>Get-ChildItem -Path "Cert:\*" -Recurse -CodeSigningCert This command gets all of the certificates in the Windows PowerShell Cert: drive that have code-signing authority. The first command imports the Microsoft.PowerShell.Security module into the session. This module includes the Cert ... The second command uses the Get-ChildItem cmdlet. The value of the Path parameter is the Cert: drive ... ... |
Ein weiteres Beispiel aus der IT Administrations Praxis sind die DHCP Server logs.
Frage: Der Client AR-IT mit der MAC Adresse "90dd5d8e6d34" und der IP 10.12.1.29 verhält sich komisch. Lieber DHCP Server: weißt du irgendwelche Details?
Lösungsweg:
$pattern = "AR-IT","90dd5d8e6d34","10.12.1.29" # Eins von den dreien soll vorkommen
Get-Content C:\Windows\System32\dhcp\DhcpSrvLog-Die.log | Out-String -Stream |Select-String -Pattern $pattern -SimpleMatch
1 2 3 4 5 6 7 8 9 10 11 12 |
PS C:\> $pattern = "AR-IT","90dd5d8e6d34","10.12.1.29" PS C:\> Get-Content C:\Windows\System32\dhcp\DhcpSrvLog-Die.log | Out-String -Stream |Select-String -Pattern $pattern -SimpleMatch 11,02/04/20,00:02:09,Erneuern,10.12.1.29,AR-IT.ad.firma.de,90DD5D8E6D34,,3564366365,0,,,,,,,,,0 11,02/04/20,00:02:09,Erneuern,10.12.1.29,AR-IT.ad.firma.de,90DD5D8E6D34,,3564366365,0,,,,,,,,,0 11,02/04/20,00:06:56,Erneuern,10.12.1.29,AR-IT.ad.firma.de,90DD5D8E6D34,,3597920797,0,,,,,,,,,0 11,02/04/20,00:06:56,Erneuern,10.12.1.29,AR-IT.ad.firma.de,90DD5D8E6D34,,3597920797,0,,,,,,,,,0 11,02/04/20,00:08:26,Erneuern,10.12.1.29,AR-IT.ad.firma.de,90DD5D8E6D34,,3631475229,0,,,,,,,,,0 11,02/04/20,00:08:26,Erneuern,10.12.1.29,AR-IT.ad.firma.de,90DD5D8E6D34,,3631475229,0,,,,,,,,,0 11,02/04/20,00:10:25,Erneuern,10.12.1.29,AR-IT.ad.firma.de,90DD5D8E6D34,,3665029661,0,,,,,,,,,0 11,02/04/20,00:10:25,Erneuern,10.12.1.29,AR-IT.ad.firma.de,90DD5D8E6D34,,3665029661,0,,,,,,,,,0 11,02/04/20,00:11:35,Erneuern,10.12.1.29,AR-IT.ad.firma.de,90DD5D8E6D34,,3698584093,0,,,,,,,,,0 |
Antwort: O.K., der DHCP Client Dienst vom AR-IT spinnt und fragt alle 1-4 Minuten nach einer neuen IP Adresse. Reboot tut gut. Problem ist gelöst 🙂
Was denken Sie?