powershell - Multiple Variables for "-name" parameter in "New-Item" -


i'm having issues following ps script:

new-item -name $infolog -path $logpath -name ("info log - ",$datestamp," - ",$timestamp) -type file 

it gives me error-

cannot bind parameter because parameter 'name' specified more once. provide multiple values parameters can accept multiple values, use array syntax. example, "-parameter value1,value2,value3".

any ideas? tried without parentheses.

all powershell cmdlets accept 1 argument per parameter. however, passed 2 arguments -name parameter of new-item:

new-item -name $infolog -path $logpath -name ("info log - ",$datestamp," - ",$timestamp) -type file # 1 argument ^^^^^^^^     argument ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

because illegal function call, powershell raising error.


it looks meant write this:

new-item -path $logpath -name "info log - $datestamp - $timestamp" -type file 

the variables in string "info log - $datestamp - $timestamp" expanded values represent:

ps > $a = 123    ps > $b = "abc" ps > "$a -- $b" 123 -- abc  ps >  

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -