powershell - Configuration Manager -
i'me new powershell don't bit me :) question this: have setup 2 types of machine x86 , x64. during setup have check version of .net framework install on machine. i'm doing invoking test-path: test-key "hklm:\software\wow6432node\microsoft\net framework setup\ndp\v1.1.4322" "install" i'd this: # check if system x64 architecture # in case of positive answere change registry # wow6432node if($os_architecture -eq "x64") { $dot_net_registry_root_path = "hklm:\software\wow6432node" }
# add common framework path $dot_net_registry_path = $dot_net_registry_root_path + "\net framework setup\ndp\" # check 1.0 version of .net framework $dot_net_1_0_registry_path = $dot_net_registry_root_path + "\microsoft\.netframework\v1.0\sbsdisabled" if(!(test-key $dot_net_1_0_registry_path "install")) { write-output ".net framework v1.0.3705 not installed" } else { write-output ".net framework v1.0.3705 installed" } # check 1.1 version of .net framework $dot_net_1_1_registry_path = "'" + $dot_net_registry_path + "v1.1.4322" + "'" if (!(test-key $dot_net_1_1_registry_path "install")) { write-output "please install .net framework v1.1.4322" } else { write-output ".net framework v1.1.4322 installed" } where test-key
function test-key([string]$path, [string]$key) { if(!(test-path -literalpath $path)) { return $false } if ((get-itemproperty $path).$key -eq $null) { return $false } return $true } the problem when i'm using variable instead of quoted string test-path fail because of spaces path: "\net framework setup"
what should fix this?
i end putting "" around paths certain, tried adding them test-path , get-itemproperty calls in function above:
if(!(test-path -literalpath "$path"))
if ((get-itemproperty "$path").$key
you can architecture of machine command
(get-wmiobject win32_operatingsystem).osarchitecture
Comments
Post a Comment