Vreemd probleem met PSexec

Pagina: 1
Acties:

Acties:
  • 0 Henk 'm!

  • Marc H
  • Registratie: Juni 1999
  • Laatst online: 00:30

Marc H

- - Is wakker - -

Topicstarter
Ik ben bezig met een update scriptje voor een paar computers. Om bepaalde redenen wil ik de computers alleen maar laten updaten op momenten dat het mij uitkomt.

Ik heb van MSDN een sample scriptje opgehaald die voor mij de updates kan ophalen, aangepast naar mijn eisen, daarna trigger ik dit scriptje via psexec op de diverse computers. (scriptje staat hieronder)

Het script start ik als volgt:

psexec \\computer1.domein.local "c:\upd.bat" -u \\domein.local\administrator -p PassWord


Upd.bat start alleen maar update.vbs op. (cscript.exe c:\update.vbs)

Het gekke is dat het vbs script wel goed gaat als ik het met de hand opstart terwijl ik achter de computer zit, maar niet als ik het met PSexec vanaf een andere computer opstart,
Het start dan wel met het uitzoeken van de updates, maar stopt dan na "Downloading updates..." (Regel 56, hieronder)

Ik heb al het admin account toegevoegd aan PSexec, vermoedend dat dat het probleem is, maar dat hielp ook niet.


Het update script update.vbs

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
Set updateSession = CreateObject("Microsoft.Update.Session")
updateSession.ClientApplicationID = "MSDN Sample Script"

Set updateSearcher = updateSession.CreateUpdateSearcher()

WScript.Echo "Searching for updates..." & vbCRLF

Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")

WScript.Echo "List of applicable items on the machine:"

For I = 0 To searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    WScript.Echo I + 1 & "> " & update.Title
Next

If searchResult.Updates.Count = 0 Then
    WScript.Echo "There are no applicable updates."
    WScript.Quit
End If

WScript.Echo vbCRLF & "Creating collection of updates to download:"

Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")

For I = 0 to searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    addThisUpdate = false
    If update.InstallationBehavior.CanRequestUserInput = true Then
        WScript.Echo I + 1 & "> skipping: " & update.Title & _
        " because it requires user input"
    Else
        If update.EulaAccepted = false Then
            WScript.Echo I + 1 & "> note: " & update.Title & _
            " has a license agreement that must be accepted:"
            WScript.Echo update.EulaText
            WScript.Echo "Do you accept this license agreement? (Y/N)"
            update.AcceptEula()
            addThisUpdate = true
        Else
            addThisUpdate = true
        End If
    End If
    If addThisUpdate = true Then
        WScript.Echo I + 1 & "> adding: " & update.Title 
        updatesToDownload.Add(update)
    End If
Next

If updatesToDownload.Count = 0 Then
    WScript.Echo "All applicable updates were skipped."
    WScript.Quit
End If
    
WScript.Echo vbCRLF & "Downloading updates..."

Set downloader = updateSession.CreateUpdateDownloader() 
downloader.Updates = updatesToDownload
downloader.Download()

Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")

rebootMayBeRequired = false

WScript.Echo vbCRLF & "Successfully downloaded updates:"

For I = 0 To searchResult.Updates.Count-1
    set update = searchResult.Updates.Item(I)
    If update.IsDownloaded = true Then
        WScript.Echo I + 1 & "> " & update.Title 
        updatesToInstall.Add(update)    
        If update.InstallationBehavior.RebootBehavior > 0 Then
            rebootMayBeRequired = true
        End If
    End If
Next

If updatesToInstall.Count = 0 Then
    WScript.Echo "No updates were successfully downloaded."
    WScript.Quit
End If

If rebootMayBeRequired = true Then
    WScript.Echo vbCRLF & "These updates may require a reboot."
End If

WScript.Echo  vbCRLF & "Would you like to install updates now? (Y/N)"
strInput ="Y"
WScript.Echo 

If (strInput = "Y" or strInput = "y") Then
    WScript.Echo "Installing updates..."
    Set installer = updateSession.CreateUpdateInstaller()
    installer.Updates = updatesToInstall
    Set installationResult = installer.Install()
    
    'Output results of install
    WScript.Echo "Installation Result: " & _
    installationResult.ResultCode 
    WScript.Echo "Reboot Required: " & _ 
    installationResult.RebootRequired & vbCRLF 
    WScript.Echo "Listing of updates installed " & _
    "and individual installation results:" 
    
    For I = 0 to updatesToInstall.Count - 1
        WScript.Echo I + 1 & "> " & _
        updatesToInstall.Item(i).Title & _
        ": " & installationResult.GetUpdateResult(i).ResultCode         
    Next
End If

Ik maak geen fouten, ik creëer leer momenten.


Acties:
  • 0 Henk 'm!

  • Brahiewahiewa
  • Registratie: Oktober 2001
  • Laatst online: 30-09-2022

Brahiewahiewa

boelkloedig

En als je
psexec \\computer1.domein.local cmd.exe -u \\domein.local\administrator -p PassWord
doet en daarna c:\upd.bat (of meteen cscript c:\update.vbs)?

QnJhaGlld2FoaWV3YQ==


Acties:
  • 0 Henk 'm!

  • DukeBox
  • Registratie: April 2000
  • Nu online

DukeBox

loves wheat smoothies

\\domein.local\administrator is niet de juiste notatie. Dat moet zijn domain.local\administrator zonder de 2 leading back slashes.

Duct tape can't fix stupid, but it can muffle the sound.


Acties:
  • 0 Henk 'm!

  • TheVMaster
  • Registratie: Juli 2001
  • Laatst online: 10-10 20:53

TheVMaster

Moderator WOS
Helemaal met DukeBox eens.

Acties:
  • 0 Henk 'm!

  • Marc H
  • Registratie: Juni 1999
  • Laatst online: 00:30

Marc H

- - Is wakker - -

Topicstarter
Tnx, ik ga dat eens proberen :)

Ik maak geen fouten, ik creëer leer momenten.


Acties:
  • 0 Henk 'm!

  • Brahiewahiewa
  • Registratie: Oktober 2001
  • Laatst online: 30-09-2022

Brahiewahiewa

boelkloedig

Hmmz, als je credentials niet kloppen, zou ik verwachten dat 't script al in regel 1 zou stoppen

QnJhaGlld2FoaWV3YQ==


Acties:
  • 0 Henk 'm!

  • DiGyPh0
  • Registratie: Juni 2001
  • Laatst online: 10-10 19:54
Voeg de -s optie eens toe
code:
1
psexec \\computer1.domein.local -s cmd.exe -u \\domein.local\administrator -p PassWord

π-♭

Pagina: 1