How to query environment variable from powershell -
i want below environment variable queried in remote server if (($imagename -like "devel") -or ($imagename -like "hosted")) , want create condition if below variable below variable value found on server "ade instalation success" else " ade instalation failed"
variable name :ade_infra variable value : \\scavere01-zfs.us.oim.com\ade_infra variable name :ade_packages variable value : \\scavere01-zfs.us.oim.com\packages\windows
i have created script below, script dont give output. not sure whether correct methord call , read system variables. can 1 ?
if (($imagename -like "*devel*") -or ($imagename -like "*hosted*")) { $env= (gci env:*).getenumerator() | sort-object name | out-string if (ade_infra -eq "\\scavere01-zfs.us.oim.com\ade_infra" -and ade_packages -eq "\\scavere01-zfs.us.oim.com\packages\windows") { $ade = "ade installation success" echo "ade = ade installation success" } if (ade_infra -eq $null -and ade_packages -eq $null) { $ade = "ade installation failed" echo "ade = ade installation failed" } }
this should fix issues having code:
if (($imagename -like "*devel*") -or ($imagename -like "*hosted*")) { $ade_infra = (gci env:ade_infra).value $ade_packages = (gci env:ade_packages).value if ($ade_infra -eq "\\scavere01-zfs.us.oim.com\ade_infra" -and $ade_packages -eq "\\scavere01-zfs.us.oim.com\packages\windows") { $ade = "ade installation success" } else { $ade = "ade installation failed" } write-host "ade = $ade" }
Comments
Post a Comment