i have a requirement in powershell if filename contains abc then set $tablename to abc_stg if filename contains pqr set $tablename to pqr_stg. Can anyone help.
switch ($file_name) {
abc {"dbo.abc_stg"}
pqr {"dbo.pqr_stg"}
}
See this page: Using Wildcards with the Switch Statement
In your case:
$tablename = switch -wildcard ($file_name)
{
"*abc*" { "dbo.abc_stg" }
"*pqr*" { "dbo.pqr_stg" }
default { "No match" }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.