Hi im having diffeculties to get my script working: It keeps failing on the first write output, even when the powershell version is higher then 4. It only works when i remove And $winver -eq $os1 -or $os2 -or $os3.
Otherwise it keeps telling me my powershell version needs to be upgraded. Im on V5 currently and $PSVersionTable.PSVersion.Major does says it 5 indeed. What am i doing wrong?
$winver = (Get-WmiObject -class Win32_OperatingSystem).Caption
$powershellversion = $PSVersionTable.PSVersion.Major
$os1 = "Microsoft Windows 7 Proffesional"
$os2 = "Microsoft Windows 10 Proffesional"
$os3 = "Microsoft Windows 10 Enterprise"
if ($powershellversion -lt 4 -And $winver -eq $os1 -or $os2 -or $os3){
Write-Output "Upgrade Powershell Version"
Exit 1010
}
else{
$bitlockerkey = (Get-BitLockerVolume -MountPoint C).KeyProtector.RecoveryPassword
$pcsystemtype = (Get-WmiObject -Class Win32_ComputerSystem).PCSystemType
if ($pcsystemtype -eq "2"){
$setsystemtype = "laptop"
}
else {
$setsystemtype = "desktop"
}
if ($winver -eq $os1 -or $os2 -or $os3){
Write-Host "$bitlockerkey"
Exit 0
}
if ($winver -eq $os1 -or $os2 -or $os3){
Write-Host "$bitlockerkey"
Exit 0
}
if ($setsystemtype -eq "laptop" -And $bitlockerkey -eq $null -And $winver -eq $os1 -or $os2 -or $os3){
Write-Host "$setsystemtype has bitlocker disabled"
Exit 1010
}
if ($setsystemtype -eq "desktop" -And $bitlockerkey -eq $null -And $winver -eq $os1 -or $os2 -or $os3){
Write-Host "$setsystemtype has bitlocker disabled"
Exit 0
}
else
{
Write-Output "Winver doesnt support Encryption"
Exit 0
}
}
Aucun commentaire:
Enregistrer un commentaire