The image above is my issue. After I click run with PowerShell it asks for variables meanwhile I have it set in the following code:
$name = "Action"$value = 0x00000001 New-ItemProperty -Path $f1_key_path -Name $name -Value $value -PropertyType DWORDI was hoping by declaring these variables I would be able to not have to use the terminal to write the inputs into the script. I have more cmdlets like this and they are all asking for input is there any reason why? If so how could I get it to use my variables I declared.
1 Answer1
In order to have parameters on different lines like you have there, the last character on a line (except on the last line) needs to be a backtick (`). So your code should look like:
$name = "Action"$value = 0x00000001 New-ItemProperty -Path $f1_key_path ` -Name $name ` -Value $value ` -PropertyType DWORDMake very sure that there is no space or anything after the backtick. Personally I advise against doing this. I would recommend building a hashtable, and thensplatting that hashtable like this:
$NewItemParams = @{ Name = 'Action' Value = 0x00000001 Path = $f1_key_path PropertyType = 'DWORD'}New-ItemProperty @NewItemParams1 Comment
Explore related questions
See similar questions with these tags.

