Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Command to run on multiple computers where winrm is disabled

$
0
0

The main idea is to find out Certificates expiring on remote servers.

When the below command is run on individual servers, it gives the desired output.

Get-ChildItem -path Cert:\LocalMachine\My |select Issuer,NotAfter | select-string "^(?!.*MACHINE)" | out-file -filepath $logfile -append

But when i run it as a script to run on multiple computers it doesnt work. (WINRM is disabled)

$servers = Get-Content -path "C:\Servers.txt"

ForEach ($server in $servers)

{Enter-PSSession -computerName $server

Get-ChildItem -path Cert:\LocalMachine\My |select Issuer,NotAfter | select-string "^(?!.*MACHINE)" | out-file -filepath $logfile -append

exit-pssession}

 

Can somebody help me complete the script.


Viewing all articles
Browse latest Browse all 6937

Trending Articles