0

有没有办法更新现有 iFile 的内容?我没有看到任何更新内容的方法。因此,我开始考虑通过使用 iControl 将本地文件上传到 BigIP 来删除和创建文件。我知道有两个对象可以使用 - iFileFile,然后按顺序使用 iFile。

有人可以为此提供用法吗?以下是我开始的内容并得到以下错误。如果我在与 powershell 脚本相同的位置有一个名为 random_key_file1 的文件,那么 iFileFile.create() 的正确参数是什么?创建 iFileFile 对象后,如何在 iFile.create() 中使用相同的对象。

以下链接有文档但缺少使用示例:https://devcentral.f5.com/wiki/iControl.LocalLB__iFile__create.ashx https://devcentral.f5.com/wiki/iControl.LocalLB__iFileFile__create.ashx

感谢帮助。

Add-PSSnapIn iControlSnapIn

$conn = Initialize-F5.iControl -HostName $hostName -Username $username -Password $password
if($conn) {

    Try
    {
        Write-Output "Connected to load balancer - $hostName"
        $ic = Get-F5.iControl
        $iFileFileObjectNames = @("file1")
        $filePaths = @("random_key_file1")
        $ic.LocalLBiFileFile.create($iFileFileObjectNames,$filePaths)
        Write-Output ("file created")
    }
    Catch
    {
        Write-Output($error[0]|format-list -force)
    }
}   
else
{
    Write-Error "Connection to loadbalancer failed"
}

错误

Exception             : System.Management.Automation.MethodInvocationException: Exception calling "create" with "2"
                        argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/iFileFile::create()
                        Common::InvalidArgument
                        " ---> System.Web.Services.Protocols.SoapHeaderException: Exception caught in
                        LocalLB::urn:iControl:LocalLB/iFileFile::create()
                        Common::InvalidArgument

                           at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
                        message, WebResponse response, Stream responseStream, Boolean asyncCall)
                           at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[]
                        parameters)
                           at CallSite.Target(Closure , CallSite , Object , Object , Object )
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
                        funcContext, Exception exception)
                           at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
                        frame)
                           at
                        System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                        frame)
                           at
                        System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                        frame)
TargetObject          :
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : SoapHeaderException
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, D:\test.ps1: line 35
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PSMessageDetails      :
Answer this Question  0
4

0 回答 0