A faster and more modern method for setting company and location variables
An even
better, faster and more modern method for setting company and location
variables is just using the registry. In my previous article about dynamic
scripting I was using environment variables, now I just use the registry.
A sample powershell script:
|
$PC_COMPANY =
(Get-ItemProperty
HKLM:\SOFTWARE\COMPANYVAR\PC_COMPANY).PC_COMPANY Write-Output
"Original registry key: $($PC_COMPANY)" #$PC_LOCATION =
(Get-ItemProperty
HKLM:\SOFTWARE\COMPANYVAR\PC_LOCATION).PC_LOCATION #Write-Output
"Original registry key: $($PC_LOCATION)" if ((Get-WmiObject Win32_OperatingSystem).name -notmatch "XP") { $programfiles = (Get-Content env:"ProgramFiles(x86)") } $Destination =
"$ProgramFiles\Elements\ElementsOutlook\ElementsOutlook\Config\" New-Item -ItemType Directory -Path $Destination if
($PC_COMPANY -eq "COMPANY1") {
Copy-Item -Path "ConfigFiles\ COMPANY1\*"
$Destination -Recurse -Force
} else {
if ($PC_COMPANY -eq
"COMPANY2") {
Copy-Item -Path "ConfigFiles\COMPANY2\*"
$Destination -Recurse -Force
} else {
if ($PC_COMPANY -eq "COMPANY3") {
Copy-Item -Path
"ConfigFiles\COMPANY3\*" $Destination -Recurse -Force
} else {
if ($PC_COMPANY -eq "COMPANY4") {
Copy-Item -Path "ConfigFiles\COMPANY4\*"
$Destination -Recurse -Force
} else {
if ($PC_COMPANY -eq
"COMPANY5") {
Copy-Item -Path "ConfigFiles\COMPANY5\*" $Destination -Recurse -Force
} else {
if
($PC_COMPANY -eq "COMPANY6") {
Copy-Item -Path "ConfigFiles\COMPANY6\*"
$Destination -Recurse -Force
} else {
Exit
}
}
}
}
} } |
Comments
Post a Comment