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" }
}