Hi PS community, I’m trying to figure out what I’m doing wrong with my code regarding hash tables.
I am trying to assign a specific license when creating a user. This is a part of the script.
The first part one is working, but the second one, when you press 2 to get the Premium licens (numbers and hyphens are the SkuID for the licens)
you get the wrong value in the parameter. Can you please help me what I´m missing?
Kind regards Bauer
#Works great
Write-Host "Please activate License, press"1" for F3 or "2" for Premium!
1=F3 or 2=Premium"
$License = Read-Host
#"1=F3 or 2=Premium"
$hash = @{}
$hash.'1' = 'SPE_F1'
$hash.'2' = 'SPB'
$hash.' ' = '_'
Foreach ($key in $hash.Keys) {
$License = $License.Replace($key, $hash.$key)
}
$License
#Not so good :-(
Write-Host "Please activate License, press"1" for F3 or "2" for Premium!
1=F3 or 2=Premium"
$License = Read-Host
#"1=F3 or 2=Premium"
$hash = @{}
$hash.'1' = '66b55226-6b4f-492c-910c-a3b7a3c9d993'
$hash.'2' = 'cbdc14ab-d96c-4c30-b9f4-6ada7cdc1d46'
$hash.' ' = '_'
Foreach ($key in $hash.Keys) {
$License = $License.Replace($key, $hash.$key)
}
$License