September 29, 2017 at 11:58 am
I'm trying to create an enum of our SQL Servers
Add-Type -TypeDefinition @"
public enum OurServers3
{
Srv1,
Srv1\Instance1
}
"@
The backslash in the instance name is giving me headaches! Any ideas? I've tried escaping with ` and \, surrounding with double-quotes...
Any ideas?
September 29, 2017 at 4:11 pm
schleep - Friday, September 29, 2017 11:58 AMI'm trying to create an enum of our SQL Servers
Add-Type -TypeDefinition @"
public enum OurServers3
{
Srv1,
Srv1\Instance1
}
"@The backslash in the instance name is giving me headaches! Any ideas? I've tried escaping with ` and \, surrounding with double-quotes...
Any ideas?
You could also try using -
Encode-SqlName -SQLName "Srv1\Instance1"
Sue
October 2, 2017 at 5:52 am
Oddly, my editor recognizes that alias for ConvertTo-EncodedSQLName, but I get cmdlet or function not found, when I try to use it outside of the here-string.
Still getting the same errors when i put that inside the here-string.
October 3, 2017 at 3:27 pm
schleep - Monday, October 2, 2017 5:52 AMOddly, my editor recognizes that alias for ConvertTo-EncodedSQLName, but I get cmdlet or function not found, when I try to use it outside of the here-string.
Still getting the same errors when i put that inside the here-string.
That is weird - not sure when that cmdlet came out as I'm kind of sick of trying to track Powershell versions all the time.
I guess the error makes sense as that would be for Powershell and your creating a .Net type. So could be two different ways to escape it. You could try to hard code in the Powershell encoding - replace the backslash with %5C but I am guessing you already did.
I thought the escaping in .net would be the backslash you already tried so I'm out of ideas.
Sue
October 4, 2017 at 6:33 am
"...I'm kind of sick of trying to track Powershell versions all the time."
+10
---------
I've given up on this: I can validate server names other ways.
Thanks for taking the time, Sue.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply