用 Data 定义变量

用 Data 定义变量

Data a{
    'aaaaaa'
}
$a.GetType()
String

Data Strings
{
    ConvertFrom-StringData @'
    MSG_TARGET_IMAGE = Target image: '{0}'
    ERR_FILE_NO_EXISTS = The file '{0}' does not exists
'@
} 

$strings.GetType()
Hashtable

$Strings.ERR_FILE_NO_EXISTS -f 'bootmgr'
The file 'bootmgr' does not exists

$Strings.MSG_TARGET_IMAGE -f "Windows 7"
Target image: 'Windows 7'

你可能感兴趣的:(PowerShell)