Answer the question
In order to leave comments, you need to log in
Passing parameter names through variables in PowerShell?
PowerShell has Set constructs, such as
Set-Content -Path 'C:\Logs\1.txt' -Value 'Текст для вывода'
-prelace @{Ключ=Значение}
-clear @{Ключ=Значение}
-prelace @{$Key=$Value}
-clear @{$Key=$Value}
$Value= '-Value'
$Value.GetType().FullName - так мы узнаем что это System.String[]
Set-Content -Path 'C:\Logs\1.txt' $Value 'Текст для вывода'
Получим ошибку, нет параметра для приема значения 'Текст для вывода'
Answer the question
In order to leave comments, you need to log in
$parms = @{'class'='Win32_BIOS';
'computername'='SERVER-R2';
'filter'='drivetype=3';
'credential'='Administrator'
}
Get-WmiObject @parms
something like this.
$parms.computername = "whatever" - if you need to change the parameter value on the fly.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question