簡體   English   中英

使用OdiOSCommand執行Powershell腳本

[英]Executing powershell script using OdiOSCommand

我創建了一個批處理文件,該文件首先調用cmd,然后應調用powershell,讀取特定文件,然后創建一個將其編碼為UTF-8的新文件。 手動執行此腳本可以正常工作。

Oracle Data Integrator支持OSCommands,因此我使用該元素來調用為此目的而創建的批處理腳本(自動化原因)。 您可以在下面找到批處理腳本的代碼:

cmd 
powershell
"Get-Content D:\mrapateatrit\SOURCE_FILES\Puntoret.txt | Set-Content -Encoding utf8 D:\mrapateatrit\SOURCE_FILES\Puntoret_utf8.txt"
exit;

當我執行調用此腳本的ODI程序包時,它會將其輸出到文件:

C:\Users\lori\Desktop>cmd  
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\lori\Desktop>

這意味着它僅在代碼中調用cmd,但沒有讀取powershell命令。 該元素可以采用的一些參數:

Command to execute: I provided the path of the batch script
Output file directory: path provided
Error file directory: Error file path provided
Working directory: desktop path provided

如果有人可以幫助我創建通過ODI調用該腳本的理想方法,那將真的很有幫助。

使用以下代碼解決了該問題: cmd /c C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -command "Get-Content D:\\mrapateatrit\\SOURCE_FILES\\Puntoret.txt | Set-Content -Encoding utf8 D:\\mrapateatrit\\SOURCE_FILES\\Puntoret_utf8.txt"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM