Collect Windows system error description from within the commandline

When validating log files, you can be confronted with some error codes without a human-readable meaning. I used to Google them always, but shortly I discovered a new- and faster way to do the job.

Open a command prompt and execute the following command: “net helpmsg <code>“.

For example:
“C:\Users\Administrator>net helpmsg 5
Access is denied.”

Quickly discover the NTP configuration on Windows

This is something I need to look up every time. Today I came across a commandline tool called: w32tm that I wanted to share.

Executing the command “w32tm /query /status” in a command prompt gives you the following information. This is in most scenarios more than sufficient.

C:\Users\user>w32tm /query /status
Leap Indicator: 0(no warning)
Stratum: 6 (secondary reference – syncd by (S)NTP)
Precision: -6 (15.625ms per tick)
Root Delay: 0.6088104s
Root Dispersion: 0.1670766s
ReferenceId: 0xAC110834 (source IP: 172.17.8.52)
Last Successful Sync Time: 9/25/2014 12:59:23 PM
Source: <source>
Poll Interval: 14 (16384s)

Continue reading

Disable UAC for administrator using Powershell

Commandline configurations are my favorited. They are very usefull to be used in standard Configuration scripts. This evening I stumbled across this one and wanted to share it. The command uses the registry to perform the change. This allows also other configurations to be injected. My life just got a little bit easier once again…

Set-ItemProperty -Path registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA -Value 1

PowerShell script reboot check

Today, I received a mail notification that a given server is not available anymore. The error was sent around 6:10 in the morning. The server is a management server not managed by our team.

To decrease the time required if the reboot was caused by Windows updates (which was the reason in the past), I quickly wrote a little PowerShell script to determine the cause.

PS C:\Users\rur> Get-EventLog -LogName System -after (get-date).addhours(-48) | where {($_.EventId -eq 1074) -or ($_.EventId -eq 22)} | select TimeGenerated,EventId,Message | format-table -wrap -autosize

Continue reading

Abort an unresponsive Data Protector job

Sometimes aborting a job by using the Data Protector Manager Console does not succeed.
In those situation, follow this procedure:

  • Go to the Data Protector Manager console > Monitor > Session-Id and take a not of the start time.
    [Normal] From: BSM@CellManager.lab.local “FILE_DAILY” Time: 5/23/2013 4:15:05 AM
    Backup session 2013/05/23-13 started.
  • Open a PowerShell Window and execute the following command: “get-process b* | sort-object StartTime | format-table Name,Id,StartTime”
    Name Id StartTime
    —- — ———
    bsm 8532 18/05/2013 4:15:07
    bsm 8996 19/05/2013 5:15:05
    bsm 11672 23/05/2013 4:15:05
  • Execute the following command to kill the process: “stop-process 8532“.

Execute the command “omnistat” or “get-process b* | sort-object StartTime | format-table Name,Id,StartTime” to verify the operation. Restart the Data Protector Management console to clear the monitor in the GUI.

List logged on users command line

Most geeks prefer a command line manner to perform operational activities. The commands below allow listing logged on users for a particular server, as well as the ability to kick them. This can be handy when you receive a “The Terminal server exceeded has exceeded the maximum number of allowed connections”-notification.

C:\Users\ruben renders>qwinsta /SERVER:SAMPLE
SESSIONNAME USERNAME ID STATE TYPE DEVICE
0 Disc rdpwd
rdp-tcp 65536 Listen rdpwd
console 4 Conn wdcon
User01 2 Disc rdpwd
rdp-tcp#26 User02 1 Active rdpwd

C:\Users\ruben renders>rwinsta 2 /SERVER:SAMPLE

Continue reading

PowerCLI – list virtual machines with physical SCSI controllers & inventory path within vcenter

For a project, we needed to implement a VEEAM Backup & Replication setup. During the project we encountered some virtual machines with Physical RDMs. VEEAM cannot handle this, so it was needed to write a script allowing us to list all virtual machines with their most interesting parameters, such as:

  • Virtual Machine Name
  • Version
  • PowerState
  • HardDisks
  • ProvisionedSpaceGB
  • Datacenter
  • Cluster
  • InventoryPath
  • HasPhysicalController

The function Get-VMFolderPath can be found on this blog.

Continue reading