Solved

PowerShell Get Windows Update Issue

Posted on 2015-01-26
2
124 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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