Solved

PowerShell Get Windows Update Issue

Posted on 2015-01-26
2
136 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
A procedure for exporting installed hotfix details of remote computers using powershell
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

740 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