Forum Discussion
jasm_146487
Nimbostratus
Mar 09, 2015How to create local users using iControl and Powershell
Can someone help me by providing sample code of how I can create a regular user on BIG-IP (11.5) using iControl and Powershell?
2 Replies
- Michael_Jenkins
Cirrostratus
Try this. It works for me in 11.5.0. Understanding the API a little bit comes from here.
region Check that SnapIn is installed try { Add-PSSnapIn -Name iControlSnapIn -ErrorAction Stop; } catch { Write-Host " iControlSnapin is not installed." -ForegroundColor Red; Write-Host " Download the snapin from https://devcentral.f5.com/d/microsoft-powershell-with-icontrol" -ForegroundColor Red; Exit the script return; } endregion region Credentials if ($f5Credentials -eq $null) { $f5Credentials = $(Get-Credential -Message "Credentials for F5 server connection"); } Write-Verbose " Credentials: $($f5Credentials.Username)"; endregion region Create the User Establish the connection to the BIG-IP server $iConn = Initialize-F5.iControl -HostName "SERVER" -Username $f5Credentials.Username -Password $f5Credentials.GetNetworkCredential().Password; if (!$iConn) { throw "Connection could not be established to $($connSrc.Server)."; return; } Get the iControl object $iCtrl = Get-F5.iControl; Create the UserInfo3 object $userInfo = New-Object iControl.ManagementUserManagementUserInfo3; User $userInfo.User = New-Object iControl.ManagementUserManagementUserID; $userInfo.User.name = "USERNAME"; $userInfo.User.full_name = "NAME"; Password $userInfo.Password = New-Object iControl.ManagementUserManagementPasswordInfo; $userInfo.Password.is_encrypted = $false; $userInfo.Password.password = "PASSWORD"; Permissions $perms = New-Object iControl.ManagementUserManagementUserPermission; $perms.partition = "[All]"; Or name of single partition $userInfo.Permissions = $perms; Login Shell $userInfo.login_shell = "/bin/bash"; Bash: "/bin/bash" || TMSH only: "/bin/false"; Execute the create function $iCtrl.ManagementUserManagement.create_user_3($userinfo) endregion - jasm_146487
Nimbostratus
ah!
You use iControl even though you specify $iCtrl = Get-F5.iControl;
I was using $iCtrl to specify the objects defined later on in the script
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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