Answer by Ramandeep Singh for How can you use an object's property in a...
If you want to use properties within quotes follow as below. You have to use $ outside of the bracket to print property.$($variable.property)Example:$uninstall= Get-WmiObject -ClassName Win32_Product |...
View ArticleAnswer by mklement0 for How can you use an object's property in a...
Documentation note: Get-Help about_Quoting_Rules covers string interpolation, but, as of PSv5, not in-depth.To complement Joey's helpful answer with a pragmatic summary of PowerShell's string expansion...
View ArticleAnswer by loonison101 for How can you use an object's property in a...
@Joey has a good answer. There is another way with a more .NET look with a String.Format equivalent, I prefer it when accessing properties on objects:Things about a car:$properties = @{ 'color'='red';...
View ArticleAnswer by Steven Murawski for How can you use an object's property in a...
@Joey has the correct answer, but just to add a bit more as to why you need to force the evaluation with $():Your example code contains an ambiguity that points to why the makers of PowerShell may have...
View ArticleAnswer by Joey for How can you use an object's property in a double-quoted...
When you enclose a variable name in a double-quoted string it will be replaced by that variable's value:$foo = 2"$foo"becomes"2"If you don't want that you have to use single quotes:$foo =...
View ArticleHow can you use an object's property in a double-quoted string?
I have the following code:$DatabaseSettings = @();$NewDatabaseSetting = "" | select DatabaseName, DataFile, LogFile, LiveBackupPath;$NewDatabaseSetting.DatabaseName =...
View Article