2017-06-07 29 views
0

タスクスケジューラの外側と内側でスクリプトを実行できます。しかし、スケジュールされたタスクはトリガされたときに自動的にスクリプトを実行しません。ユーザーアカウント制御:Built-i Administratorアカウントの管理者承認モード(未定義) - ユーザーアカウント制御:すべての管理者を管理者承認モード(無効)で実行する - ユーザーアカウント制御:動作Admin Approval Mode(プロンプトなしでElevate)で管理者の昇格プロンプトを表示します。これはうまくいかなかった。どんな助けも素晴らしいだろう。ありがとう。Powershellスクリプトがスケジュールされたタスクで実行されていない

enter image description here

enter image description here

enter image description here

プログラム/スクリプト:C:\ WINDOWS \ System32に\ WindowsPowerShell \ v1.0をするの\たpowershell.exe

はargrumentsを追加します。-noprofile -ExecutionPolicyバイパス - ファイルC:\ Users \ Andersen \ Desktop \ moveFiles.ps1

enter image description here

enter image description here

Try 
{ 

$Time = Get-Date 

if(Test-Path C:\Users\Andersen\Desktop\src) { 
    "Source exists." 
} else { 
    Write-Output "This script made a read attempt at [$Time]. Source (C:\Users\Andersen\Desktop\src) cannot be found." | out-file C:\Users\Andersen\Desktop\KofaxScriptErrorLog.txt -Append 
    Exit 
} 

$IDsrc = (Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\ID - Sub Invoice").Count 
$Jsrc = (Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\J - Sub Invoice").Count 
$ORsrc = (Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\OR - Sub Invoice").Count 
$OR2 = (Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\OR2 - Sub Invoice").Count 
$SCsrc = (Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\SC Invoice").Count 
$WAsrc = (Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\WA - Sub Invoice").Count 

# move Kofax ID files to ID folder in Egnyte 
If ($IDsrc -ne 0){ 
Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\ID - Sub Invoice" -Recurse -ErrorAction Stop | 
    Move-Item -Destination "C:\Users\Andersen\Desktop\Current Imaging\ID - Sub Invoice" -Force -ErrorAction Stop 
    } 
# move Kofax J files to J folder in Egnyte 
If ($Jsrc -ne 0){ 
Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\J - Sub Invoice" -Recurse -ErrorAction Stop | 
    Move-Item -Destination "C:\Users\Andersen\Desktop\Current Imaging\J - Sub Invoice" -Force -ErrorAction Stop 
    } 
# move Kofax OR files to OR folder in Egnyte 
If ($ORsrc -ne 0){ 
Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\OR - Sub Invoice" -Recurse -ErrorAction Stop | 
    Move-Item -Destination "C:\Users\Andersen\Desktop\Current Imaging\OR - Sub Invoice" -Force -ErrorAction Stop 
    } 
# move Kofax OR2 files to OR2 folder in Egnyte 
If ($OR2src -ne 0){ 
Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\OR2 - Sub Invoice" -Recurse -ErrorAction Stop | 
    Move-Item -Destination "C:\Users\Andersen\Desktop\Current Imaging\OR2 - Sub Invoice" -Force -ErrorAction Stop 
    } 
# move Kofax SC(multi) files to SC(multi) folder in Egnyte 
If ($SCsrc -ne 0){ 
Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\SC Invoice" -Recurse -ErrorAction Stop | 
    Move-Item -Destination "C:\Users\Andersen\Desktop\Current Imaging\SC Invoice" -Force -ErrorAction Stop 
        } 
# move Kofax WA files to WA folder in Egnyte 
If ($WAsrc -ne 0){ 
Get-ChildItem -Path "C:\Users\Andersen\Desktop\src\WA - Sub Invoice" -Recurse -ErrorAction Stop | 
    Move-Item -Destination "C:\Users\Andersen\Desktop\Current Imaging\WA - Sub Invoice" -Force -ErrorAction Stop 
    }  

} 


Catch { 

$ErrorMessage = $_.Exception.Message 
$FailedItem = $_.Exception.ItemName 
    "The script to move files from the Kofax server to Egynte made a run attempt at $Time. Error Details: $ErrorMessage $FailedItem" | out-file C:\Users\Andersen\Desktop\KofaxScriptErrorLog.txt -Append 
    Break 
} 

Finally 
{ 

    "This script made a complete read attempt at $Time" | out-file C:\Users\Andersen\Desktop\KofaxScriptLog.txt -Append 
} 
+0

メンバー? – notjustme

+0

'-ExecutionPolicy Unrestricted'を試しましたか?また、動作が同じかどうかを直接ps1ファイルに設定するのではなく、Powershellスクリプトを起動する "Program/Script:"でバッチを使用することもできます。 – Manu

+0

@notjustmeはい「バッチジョブとしてログオンする」に自分自身を追加しました – DigitalSea

答えて

0

コールあなたのscheduldedタスクでたpowershell.exe:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe 

設定し、この引数:バッチとしてログオンの

-noprofile -executionpolicy unrestricted -noninteractive -file "C:\Path\To\MyScript.ps1" 
0

あなたが無制限にあなたの実行を持っていることを確認します。

​​

そしてProgram\Scriptセクションに次のアクションを追加して、表示されるプロンプトにYesをクリックしてください。あなたが無制限にあなたの実行ポリシーを設定することができない場合

PowerShell.exe "& 'C:\LocationFolder\YourScript.ps1'" 

だけで上記のコマンドに-NoProfile -ExecutionPolicy Bypassを追加します。

関連する問題