Hallo,
ik heb een simpele powershell-functie aangemaakt als volgt:
Wanneer ik echter dan later deze functie aanroep als volgt:
Dan krijg ik de foutmelding Cannot validate argument on parameter 'Path' because it is null. .... De variabele $regpath zou dus null zijn.
Ik begrijp er niets meer van.
ik heb een simpele powershell-functie aangemaakt als volgt:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| $global:rtgpath = "HKLM:\SOFTWARE"
....
function Set_RegistryKey($regkeyname, $regpath, $type, $regvalue)
{
if(!(Test-Path $regpath))
{
New-Item -Path $regpath -Force | Out-Null
New-ItemProperty -Path $regpath -Name $regkeyname -PropertyType $type -Value $regvalue | Out-null
}
else
{
New-ItemProperty -Path $regpath -Name $regkeyname -PropertyType $type -Value $regvalue | Out-null
}
} |
Wanneer ik echter dan later deze functie aanroep als volgt:
code:
1
| Set_RegistryKey("abc", $global:rtgpath, "string", "def") |
Dan krijg ik de foutmelding Cannot validate argument on parameter 'Path' because it is null. .... De variabele $regpath zou dus null zijn.
Ik begrijp er niets meer van.