Amending script to read list of computers, run script and output to log file
Hello all,
I have cobbled together a script that runs and does what I want, now I would like to amend the script to read a list of computers rather than use the msg box that it is currently using for the strcomputer, if the computers doesn't respond to a ping, then
log that, if it does continue with the script and when it is complete, log a success or failure. I have just started scripting and would really appreciate some help on this one,thanks. I created the script to fix an SCCM updates issue and failing task sequences,
so it may prove useful to others.
There are msg box entries that can be removed that were originally in there for the user running the script.
'setting objects
Dim net, objFSO, shell
Dim objFile, strLine, intResult
Set objnet = CreateObject("wscript.network")
Set objFSO = CreateObject("scripting.filesystemobject")
Set objshell = CreateObject("wscript.shell")
strfile = "c:\wuafix\wuafix.vbs"
strUser = "domain\user"
strPassword = "password"
'getting server name or IP address
strComputer=InputBox("Enter the IP or computer name of the remote machine on which to repair the WUA agent:", "Starting WUA Fix")
'check to see if the server can be reached
Dim strPingResults
Set pingExec = objshell.Exec("ping -n 3 -w 2000 " & strComputer) 'send 3 echo requests, waiting 2secs each
strPingResults = LCase(pingExec.StdOut.ReadAll)
If Not InStr(strPingResults, "reply from")>0 Then
WScript.Echo strComputer & " did not respond to ping."
WScript.Quit
End If
'Check if source file exists
If Not objFSO.FileExists(strFile) Then
WScript.Echo "The source file does not exist"
WScript.Quit
End If
MsgBox "The WUA Fix is in process. Please wait.", 64, "Script Message"
'mapping drive to remote machine
If objFSO.DriveExists("Z:") Then
objnet.RemoveNetworkDrive "Z:","True","True"
End If
objnet.MapNetworkDrive "Z:", "\\" & strComputer & "\c$", True
'creating folder for install exe on remote machine
If (objFSO.FolderExists("Z:\wuafix\") = False) Then
objFSO.CreateFolder "Z:\wuafix"
End If
'copying vbs to remote machine
objFSO.CopyFile strFile, "Z:\wuafix\wuafix.vbs"
'set command line executable to run a silent install remotely
strInstaller1 = "cscript.exe c:\wuafix\wuafix.vbs"
'strInstaller2 = "c:\wuafix\wuafix.vbs"
strExec = "c:\pstools\PsExec.exe "
'objshell.Run strExec & " \\" & strComputer & strInstaller1
On Error Resume Next
result = objshell.Run(strExec & " \\" & strComputer & " " & strInstaller1)
If Err.Number = 0 Then
WScript.Echo "PSXEC Runing WUA fix remotely"
Else MsgBox Err.Number
MsgBox result
End If
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
("SELECT * FROM Win32_NTLogEvent WHERE Logfile = 'Application' AND " _
& "EventCode = '4'")
Wscript.Echo "Event Viewer checked and Fix Applied:" & colLoggedEvents.Count
MsgBox "Removing mapped drive Please wait.", 64, "Script Message"
If objFSO.DriveExists("Z:") Then
objnet.RemoveNetworkDrive "Z:","True","True"
End If
MsgBox "The WUA Fix has been applied.", 64, "Script Message"
quit
wscript.quit
Any help appreciated and explanations on the process would be great as I would like to learn the process involved, which is difficult when working during the day.
many thanks
Hi Bill,
long story short, I have approx. 2800 clients with an old entry in WMI for updates that the sccm client cannot clear or run because they do not exist anymore, so the client will not run updates or use a task sequence because of this, so my script fixes this
and does a couple of other things, I have found another way to do this by running a different script that uses WMI to call a cscript function that uses the wuafix.vbs that is coped to the machine, I am also changing the echo entries to output to a log
file instead so that I can track what client has run the fix andn which ones haven't.
If you have any suggestions then please let me know, nothing nefarious :)
many thanks
Similar Messages
-
TS4001 How to delete reading list in the book mark and history
How to delete in bookmark and reading list in safari in Ipad and iphone4
Swipe across an item in the reading list and it should get a Delete button on it - you will need to do each individually, I don't think that there is a multi-select-and-delete option
-
Since downloading 5.1.1, my Touch 3G has "Reading List" in the Bookmarks section and the "history" tab no longer shows anything.
How do I delete "reading list" in the bookmarks section? Very disappointed to have this pushed on me without warning. TIA....Please can u answer it fast
-
Oracle script:How to avoid output in log file?
Hi,
I am try to create the xml file using some sql statements in a script.
I dont want to display the output from these sql statements in log file.
I tried with SET TERMOUT OFF, even then i am getting the output.I am getting the output even after using the SET echo off.
I have given the following SET options,
SET heading off
SET feedback off
SET verify off
SET wrap off
SET pagesize 0
SET linesize 3000
SET server off
SET echo off
I do not want to display the output in log file when i run the concurrent request. -
I have a new IMAC 5k running Yosemite and when I log in I am asked a whole series of questions as to what keychain can access. How can I authorise all of these to be available upon login? Items concerned are such as "Talagent", "Messages agent" etc
Back up all data before proceeding.
Launch the Keychain Access application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad and start typing the name.
Select the login keychain from the list on the left side of the Keychain Access window. If your default keychain has a different name, select that.
If the lock icon in the top left corner of the window shows that the keychain is locked, click to unlock it. You'll be prompted for the keychain password, which is the same as your login password, unless you've changed it.
Right-click or control-click the login entry in the list. From the menu that pops up, select
Change Settings for Keychain "login"
In the sheet that opens, uncheck both boxes, if not already unchecked.
From the menu bar, select
Keychain Access ▹ Preferences... ▹ First Aid
There are four checkboxes in the window that opens. Check all of them. if they're not already checked. Close the window.
Select
Keychain Access ▹ Keychain First Aid
from the menu bar and repair the keychain. Quit Keychain Access.
If you use iCloud Keychain, open the iCloud preference pane and uncheck the Keychain box. You'll be prompted to delete the local iCloud keychain. Confirm. Then re-check the box. Follow one of the procedures described in this support article to set up iCloud Keychain on an additional device. -
How to list the contents of an OSX directory, and output to text file?
hello there any hints with any known program that does following
I have recorded my music directory to DVD and now i would like to make an .txt file what the dvd contains...cos its way of hand to write all 100xx files by hand...
How to list the contents of an OSX directory, and output to text file?
any prog that does that? any hints?
best regardsThis script makes a hierarchical file listing all files in a folder and subfolder:
Click here to launch Script Editor.
choose folder with prompt "Choose a folder to process..." returning theFolder
set theName to name of (info for theFolder)
set thepath to quoted form of POSIX path of theFolder
set currentIndex to theFolder as string
do shell script "ls -R " & thepath returning theDir
set theDirList to every paragraph of theDir
set newList to {"Contents of folder \"" & theName & "\"" & return & thepath & return & return}
set theFilePrefix to ""
repeat with i from 1 to count of theDirList
set theLine to item i of theDirList
set my text item delimiters to "/"
set theMarker to count of text items of thepath
set theCount to count of text items of theLine
set currentFolder to text item -1 of theLine
set theFolderPrefix to ""
if theCount is greater than theMarker then
set theNestIndex to theCount - theMarker
set theTally to -1
set theFilePrefix to ""
set theSuffix to ""
repeat theNestIndex times
set theFolderPrefix to theFolderPrefix & tab
set theFilePrefix to theFilePrefix & tab
if theTally is -1 then
set theSuffix to text item theTally of theLine & theSuffix
else
set theSuffix to text item theTally of theLine & ":" & theSuffix
end if
set currentIndex to "" & theFolder & theSuffix
set theTally to theTally - 1
end repeat
end if
set my text item delimiters to ""
if theLine is not "" then
if word 1 of theLine is "Volumes" then
set end of newList to theFolderPrefix & "Folder: > " & currentFolder & return
else
try
if not folder of (info for alias (currentIndex & theLine & ":")) then
set end of newList to theFilePrefix & tab & tab & tab & "> " & theLine & return
end if
end try
end if
end if
end repeat
open for access file ((path to desktop as string) & "Contents of folder- " & theName & ".txt") ¬
with write permission returning theFile
write (newList as string) to theFile
close access theFile -
how to get SQL server Total DB size , Total DB free space , Total Data & Log File Sizes and Total Data & Log File free Sizes from a list of server
Hi Shivanq,
To get a list of databases, their sizes and the space available in each on the local SQL instance.
dir SQLSERVER:\SQL\localhost\default\databases | Select Name, Size, SpaceAvailable | ft -auto
This article is also helpful for you to get DB and Log File size information:
Checking Database Space With PowerShell
I hope this helps. -
Need help creating a script to read the name of a folder (which is the AD Username) and adding that name into the permissions of that folder.
I have over 100 folders which I need to add the AD user to read and write to their own folder
Hope you guys understand what I meanJust to add, Mac in intergrated into AD and all I need is help in creating the script
Thanks -
How to sync reading list between my old tablet and new one?
I have like 100 links in my reading list in firefox on my old tablet. I need to transfer them to my new tablet, but it seems that Firefox sync is working only for bookmarks. How can I transfer my reading list without rooting the device?
Hello.
Currently, there is no way to sync your reading list between your devices. Since the reading list is just webpages without all of the ads and a more reader-like experience, it's just like a bookmark. But, you have to make all of those reading list items into bookmarks to sync between devices. The reading list is for on-device only.
Sorry for all of the trouble. (With 100 and all) :-( -
Hi,
I am getting the above error message when I try to view a PDF document from within a website.
If I navigate to the folder location where the PDF is stored and launch it from there it will open without any problems. If I go to other PCs and try to launch the same files from the same website then they will be OK. It just appears to be from this one PC.
Abode Acrobat 9.1
Internet Explorer 8
Windows 7 (32bit)
I think the issue is that someone has tried to install Adobe Reader 10 on the same PC and it has failed and left something behind (am sure I read somewhere that Adobe Reader and Acrobat can't be on the same PC as it causes issues).
I've checked C:\Program Files\Adobe and removed all references to Reader. Done the same to the Registry. Could it have installed anything anywhere else? Is there a way to make sure a failed install has been removed completely?
Thanks,
BruceHi Bruce33,
You can use the Acrobat cleaner tool to remove Acrobat / Reade completely from the machine.
You can download the tool from : http://labs.adobe.com/downloads/acrobatcleaner.html
Also make sure you update Acrobat 9 to the latest patch i.e. 9.5.5 and check.
Regards,
Rave -
My MacBook Pro (late 2011, core i-7) running OS X 10.10.4 is running hot and very slow with the fan screaming . Activity Monitor shows a process called com.hp.devicemodel.TransportProxy is hogging almost all the memory and very high CPU activity. How can I get it to stop. Force quit will not shut it down. I would delete the file, but don't know where it is. Can someone please offer some help? Thanks, Tom
Try to uninstall all HP software (should be in Macintosh HD/Applications/HP folder It should have an uninstaller within that folder. My computer settled down just as soon as I finished the uninstall. Went back into the system preferences and reinstalled my printer and everything seems OK now. Hope it works for you.
-
Re:read long raw data in Oracle and write to a file
So we need an mechanism to read data from LONG RAW and convert into actual file.
RegardsI've branched your post off from the thread you posted on ({thread:id=620757}) as it was an old thread.
When you have a question of your own, you should always start a new thread rather than tag onto old ones.
Please read: {message:id=9360002} and post some relevant information so that people can help you. -
How to run explorer and upload to support files
Hey Unix gurus
i got an issue with one of our T2000 server and when contacted sun support told us to run the explorer and upload to support files,so that they can determine the problem and fix it.can anyone help me how to run the explorer and upload the files to sun support.
I truly appreciate your assistance
Regars
etc.You can run the explorer using below command /opt/SUNWexplo/bin/explorer
and the output gets stored in gz format in /opt/SUNWexplo/output directory
To upload the explorer you can use the below link
http://supportfiles.sun.com/upload
Hope this helps -
Computers running Vista won't open PDF files with Adobe Reader
I have tried downloading the latest version and nothing helps. The error message says it was incorrectly encrypted or something along those lines. I have forwarded the file to my home computer and ith opens fine, but not on the boss's computer or his wife's. They are both running Vista, as is my home computer. The other computers in the office are older and are running XP. I hav eno problems with any of them opening PDF files.
Yep you need Adobe Reader for Intel. Actually you don't even need that. You could use Preview to view .pdf's but I always use Reader. Don't really know why
-
Sql Server Script for the List of all Country State and City
I am searching for the Sql Server Script of all country State and City with the Following type
For the Country only 2 Columns are there i.e. CountryId and CountryName(CountryId is primary Key)
For the State 3 Columns are there i.e. CountryId, StateId and StateName(StateId is Primary Key and CountryId is Foreign Key)
For the City 3 Columns are there i.e. StateId ,CityId and CityName(CityId is PrimaryKey and StateId is foreign Key).
I need this type of Script with Column name. plzzz help me out i m stuck i didnt get the list as i want.
Thanx and Regrads,Hi Vishnu,
According to your description, you want to list all countries, states and cities, right?
I have tested it on my local environment, here is a sample script for you reference.
select
[dbo].[Country].[CountryId]
, [dbo].[Country].[CountryName]
, [dbo].[State].[StateId]
, [dbo].[State].[StateName]
, [dbo].[City].[CityId]
, [dbo].[City].[CityName]
from
[dbo].[Country]
left join [dbo].[State] on [dbo].[Country].[CountryId]=[dbo].[State].[CountryId]
left join [dbo].[City] on [dbo].[State].[StateId]=[dbo].[City].[StateId]
Regards,
Charlie Liao
TechNet Community Support
Maybe you are looking for
-
I am trying to setup wireless using my old dome Airport Extreme Base station. I had previously used it about 5 years ago when I had dial up but have now switched to DSL with Windstream. I can not get connected as the ABS keeps trying to dial up(the o
-
After Migration to Server 2012 R2 One Zip Archive (7.08 mb) Downloads Empty
I recently migrated from Server 2008 R2 to 2012 R2. I offer a number of web application as zip archives and Dreamweaver Extension installer packages .mxp. I have one zip archive that's empty when downloaded with size 0. Out of all the files served th
-
Query Regarding File to IDOC Scenario (1:2)
Hi, I am working on a scenario like One File to Two IDOC's . In file we are getting some business functions (It's One feild in source file) , Some Business functions I need to map with One IDOC and some with other Idoc. So I need to route a file cont
-
Rhsnippet.apj Error with RoboHTML 11 Project on Network
I have an RH 11 project on a network drive. The project has 485 snippets. When adding or modifying snippets I get the following error: An error occurred while trying to read data from <n:\roboHelp Projects\\rhsnippet.apj <1>. When I open the rhsnippe
-
IWeb domain sites2 file can't seem to open on other computer
Thanks to the many postings, I finally found my domain sites2 file. I have iWeb08. I stored domain.site on my mobile me directory, but couldn't open it on my other computer I put it on a removeable thumb drive, and still couldn't open it. Am I missin