All,
I am using Get-WebConfigurationProperty to pull the values in the “requestquerystringsequence” section. I am then testing to ensure that the “@” symbol is present as one of the values in that collection. I can do this successfully with other characters “;,://” etc., but it fails with “@”.
I am guessing Powershell is reading this as a 'here string" or some other special character. I have tried escaping it with \ and `, to no avail. Any ideas?
[pre]
$Arr = “@”
(Get-WebConfigurationProperty -Filter system.webserver/security/requestfiltering/denyquerystringsequences/add -PSPath ‘MACHINE/WEBROOT/APPHOST’ -Name sequence | Select Value) -match $Arr
[/pre]
Thanks,
Des
Have you tried using single quotes?
(Get-WebConfigurationProperty -Filter system.webserver/security/requestfiltering/denyquerystringsequences/add -PSPath 'MACHINE/WEBROOT/APPHOST' -Name sequence | Select Value) -match '@'
Try checking this out.
Does it help?
https://stackoverflow.com/questions/51188618/powershell-escaping-special-characters-in-variable
[quote]
If it is the variable that contains Special Characters this should work. Within the @" "@ delimiters variables and sub-expressions will get expanded, but quotes and other special characters are treated as literals.[/quote]
$SpecialCharacters = @'
& "C:\Program Files\7-Zip\7z.exe" u -mx5 -tzip -r "$DestFileZip" "$DestFile"
'@
$SpecialCharacters
It should work with both single and double quotes, use Select-Object -ExpandProperty Value to expand it as a string.
Thank you @kvprasoon. Using the -ExpandProperty with the Value, solved the problem.
[pre](Get-WebConfigurationProperty -Filter system.webserver/security/requestfiltering/denyquerystringsequences/add -PSPath ‘MACHINE/WEBROOT/APPHOST’ -Name sequence | Select -ExpandProperty Value) -match $Arr[/pre]