?
Solved

PowerShell Get Windows Update Issue

Posted on 2015-01-26
2
Medium Priority
?
142 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 2000 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

762 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