Solved

PowerShell Get Windows Update Issue

Posted on 2015-01-26
2
122 Views
Last Modified: 2015-01-26
The script that I have been using has been working perfectly up until today, not sure why it is no longer properly seeing the servers.txt file. Below is the script that I have been using to get Windows Updates on a list of servers in the text file and then porting it over to a csv file. Any suggestions on the error would be greatly appreciated.

Note: If I just specify the Server Name by itself it works just fine. Not sure why the GC command stopped working.

Script:

Get-HotFix -ComputerName (gc servers.txt) |Export-Csv .\WindowsPatches.csv

Error:

Get-HotFix : Cannot validate argument on parameter 'ComputerName'. The
argument is null or empty. Supply an argument that is not null or empty and
then try the command again.
At C:\scripts\Get-WindowsServerUpdates.ps1:1 char:26
+ Get-HotFix -ComputerName (gc servers.txt) |Export-Csv .\WindowsPatches.csv
+                          ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-HotFix], ParameterBindingV
   alidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power
   Shell.Commands.GetHotFixCommand
0
Comment
Question by:robertarenson
2 Comments
 
LVL 2

Accepted Solution

by:
Marc L earned 500 total points
ID: 40571076
It looks like it is finding the server.txt file, as you are not getting a 'does not exist' error from the gc command.

Make sure there is no blank lines at the start of the servers.txt, or an illegal character. You could try copying the contents into another file.
0
 

Author Closing Comment

by:robertarenson
ID: 40571739
Thanks, not sure what happen but sure enough it was just the simple txt file that was messing things up. Thanks again
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now