BioliZards.be

DreamOn Technical Blog

Category: Scripting

Script to get Zenworks 11 Agent registration status

This script wil run the command line management interface for the Novell ZENworks Adaptive Agent that is installed on managed devices with the option security-location (sl) and  output the info in a message box.

I have written this script to implement in a installer script to wait until the agent is registered in de ZenWorks Server.

Dim WshShell, oExec, strText, strId, strName, strStream
Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec("zac sl")

Do While oExec.StdOut.AtEndOfStream <> True
strStream = trim(oExec.StdOut.ReadLine)

Select Case left(strStream,3)
Case "The"
If strstream = "The current security location is unknown." Then
strStatus = "No Location"
End If
Case "Id:"
strStatus = "Current Security Location:"
strId = strStream
Case "Nam"
strName= strStream
End Select

Loop

If strStatus = "Current Security Location:" Then
strText = strStatus & vbcrlf & strId & vbcrlf & strName
Else
strText = "The current security location is unknown."
End If

wscript.echo strText

More Console commands for Zenworks11 can be found here:
http://www.novell.com/documentation/zenworks11/pdfdoc/zen11_utils/zen11_utils.pdf

VBscript: Check OS Version Information and Detect 32-bit or 64-bit Windows

A little script to check the version of the OS

Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    Wscript.Echo "Boot Device: " & objOperatingSystem.BootDevice
    Wscript.Echo "Build Number: " & objOperatingSystem.BuildNumber
    Wscript.Echo "Build Type: " & objOperatingSystem.BuildType
    Wscript.Echo "Caption: " & objOperatingSystem.Caption
    Wscript.Echo "Code Set: " & objOperatingSystem.CodeSet
    Wscript.Echo "Country Code: " & objOperatingSystem.CountryCode
    Wscript.Echo "Debug: " & objOperatingSystem.Debug
    Wscript.Echo "Encryption Level: " & objOperatingSystem.EncryptionLevel
    dtmConvertedDate.Value = objOperatingSystem.InstallDate
    dtmInstallDate = dtmConvertedDate.GetVarDate
    Wscript.Echo "Install Date: " & dtmInstallDate
    Wscript.Echo "Licensed Users: " & _
        objOperatingSystem.NumberOfLicensedUsers
    Wscript.Echo "Organization: " & objOperatingSystem.Organization
    Wscript.Echo "OS Language: " & objOperatingSystem.OSLanguage
    Wscript.Echo "OS Product Suite: " & objOperatingSystem.OSProductSuite
    Wscript.Echo "OS Type: " & objOperatingSystem.OSType
    Wscript.Echo "Primary: " & objOperatingSystem.Primary
    Wscript.Echo "Registered User: " & objOperatingSystem.RegisteredUser
    Wscript.Echo "Serial Number: " & objOperatingSystem.SerialNumber
    Wscript.Echo "Version: " & objOperatingSystem.Version
Next

Detect 32-bit or 64-bit Windows

There are 2 options here

Set WshShell = CreateObject("WScript.Shell")

OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")

If OsType = "x86" then
wscript.echo & "Windows 32bit system detected"
elseif OsType = "AMD64" then
wscript.echo & "Windows 64bit system detected"
end if

A simpler and more correcter way would be

wscript.echo GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth

Putting this together in an Html Application (HTA) makes:

<html>
<head>
<title>Outlook ReProfiling ...</title>

<HTA:APPLICATION
ID="objHTAOutlReProfiling"
APPLICATIONNAME="OutlReProfiling"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
</head>

<style type="text/css">
div.centered{
display:block;
position:absolute;
top:5%;
left:10%;
width:80%;
}
</style>

<body>
<div id=DataAreaNL>
</div>
</doby>
<SCRIPT Language="VBScript">
Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Boot Device: " & objOperatingSystem.BootDevice & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Build Number: " & objOperatingSystem.BuildNumber & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Build Type: " & objOperatingSystem.BuildType & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Caption: " & objOperatingSystem.Caption & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Code Set: " & objOperatingSystem.CodeSet & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Country Code: " & objOperatingSystem.CountryCode & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Debug: " & objOperatingSystem.Debug & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Encryption Level: " & objOperatingSystem.EncryptionLevel & "<br>"
dtmConvertedDate.Value = objOperatingSystem.InstallDate
dtmInstallDate = dtmConvertedDate.GetVarDate
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Install Date: " & dtmInstallDate  & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Licensed Users: " & _
objOperatingSystem.NumberOfLicensedUsers & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Organization: " & objOperatingSystem.Organization & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"OS Language: " & objOperatingSystem.OSLanguage & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"OS Product Suite: " & objOperatingSystem.OSProductSuite & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"OS Type: " & objOperatingSystem.OSType & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Primary: " & objOperatingSystem.Primary & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Registered User: " & objOperatingSystem.RegisteredUser & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Serial Number: " & objOperatingSystem.SerialNumber & "<br>"
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML &"Version: " & objOperatingSystem.Version & "<br>"
Next

Set WshShell = CreateObject("WScript.Shell")

OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")

If OsType = "x86" then
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML & "Windows 32bit system detected" & "<BR>"
elseif OsType = "AMD64" then
DataAreaNL.InnerHTML=DataAreaNL.InnerHTML & "Windows 64bit system detected" & "<BR>"
end if

DataAreaNL.InnerHTML=DataAreaNL.InnerHTML & GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth & "<BR>"

</SCRIPT>
</html>

vCenter disconnect Idle connections

In the previous post I introduced you guys to basic PowerCli

Well Today I’ve got a practical example script.
Over the last few weeks we had a lot of open sessions on our vCenter server.
This from people leaving there client open and never closing them (retards, sorry for the language).
This generated some idle sessions from a few hours to a few days :-S

This got so on my nerves that I wanted a solution for this, unfortunately vmWare did not implement the feature to disconnect idle session after a specific time in the Client or vCenter settings.

So time to build a script Continue reading

Powercli small introduction

Ever needed to do some bulk operation in you’re vmware virtual environment ?
Or just needed information of a bunch of virtual machines ?

Then you probably had a lot of manual labor to do in the vShere client.
Well vmware came with  a solution:

The program is called VMware vSphere PowerCLI and more information can be found here.

A short discription in the words of vmWare:

VMware vSphere PowerCLI provides a Windows PowerShell interface to the vSphere API. vSphere PowerCLI includes PowerShell Cmdlets (pronounced, “command-lets”) for administering vSphere components. In addition, the vSphere PowerCLI package includes the vSphere SDK for .NET for developers who want to create their own applications.

Let’s get started implementing and using the PowerCli

Continue reading

© 2017 BioliZards.be

Theme by Anders NorenUp ↑