Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Oct 27, 2017

Add OSVersion Check and Bail.

Add OSVersion Check and Bail.
@@ -51,6 +51,11 @@ function GetTimestampUTC {
Get-Date (Get-Date).ToUniversalTime() -Format "yyyy-MM-ddTHH:mm:ssZ"
}

if($((Get-WmiObject Win32_OperatingSystem).Name).Contains(" XP ")){
Write-Error ("{0}: This script is not supported on Windows XP." -f (GetTimestampUTC))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not work as expected for all localized versions of Windows. Also, XP and 2K3 are the same major.minor version number, but this check only looks for XP. Better to go by the major.minor version number returned by (Get-CimInstance Win32_OperatingSystem).Version and make sure that value is greater than 5.2. From memory, I can't recall if Get-CimInstance works on all windows OS versions, need to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant