Forum Discussion
Per_Eriksson_37
Nimbostratus
Well, since no one seem to know how to do this I'm posting my own answer to my own question. 🙂
NOTE! ...and this is why I couldn't get it to work:
In order for this to work your service account that you use to log into the F5 LTM need to be administrator level
By combining the Powershell script that uploads the file (example in the initial question above) you can modify a system iFile object using PowerShell like this:
Update the existing system iFile (iFileApiKeys) with uploaded text file content
$sysiFileName = "iFileApiKeys"
$sysIfilePath = "/mgmt/tm/sys/file/ifile/" + $sysiFileName
$sysPath = "https://" + $host_address + $sysIfilePath
$sourcePath = "file:///" + "/var/config/rest/downloads/" + $ifileName
$ifleobject = Invoke-WebRequest -Method Get $sysPath -Credential $mycreds
Write-Host "System iFile object data before update:"
Write-Host $ifleobject
$headers = @{};
$headers.Add("ServerHost", $host_address);
$obj = @{
sourcePath = $sourcePath
};
$body = $obj | ConvertTo-Json
$updateresult = Invoke-WebRequest -Method Put -Uri $sysPath -Headers $headers -Credential $mycreds -Body $body
Write-Host "Update Result:"
Write-Host $updateresult
This code will generate this result:
...and as you can see the "revision" has incremented by one from 62 to 63.
Hope it can help someone else!
/Per
JRahm
Dec 10, 2018Admin
Nice work @Per!