パス変数 --> param ([string]$w) を、パスをパワー シェル スクリプトに格納する別のパラメーターに渡したいと思います。次に、別のバッチ ファイルを使用して、このパワー シェル スクリプトが呼び出されます。フルパスを完成させるフォルダ名である $ を渡すのに失敗しました。これに関する解決策を提案してください
$FilePath = "C:\Root\Main\Subfolder\param ([string]$w)\Table\"
$FileExists = Test-Path $FilePath
If ($FileExists -eq $True)
{ Get-ChildItem -path C:\Root\Main\Subfolder\param ([string]$w)\Table\ -Recurse -Filter *.sql |
` Sort-Object -Property DirectoryName -Desc | `
Foreach-Object -Process {$_.FullName } |ForEach-Object {sqlcmd -i $_}
}
Else {Write-Host "No file at this location"}
これは私のバッチファイルのコマンドラインです
PowerShell.Exe -File C:\Users\AZ\Desktop\PowerShell\untitled7.ps1 "Payment"