Forum Discussion
Per_Eriksson_37
Dec 08, 2018Nimbostratus
PowerShell - How to modify system iFile?
I use PowerShell to upload a text file containing a number of parameters that I want to use in an existing iRule.
Through the web-gui I have already created an iFile named 'iFileApiKeys'.
In Powe...
Per_Eriksson_37
Dec 10, 2018Nimbostratus
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
- JRahmDec 10, 2018Admin
Nice work @Per!
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects