This is a Powershell Module that provides command-lines and automation for the TrueNAS API.
With this module, you can manage your TrueNAS server from a computer with Powershell (Windows and Linux).
- This module only works over HTTPS.
- This module only works with TrueNAS API Key.
- Powershell 7.1 Minimum (for a better experience) but works on Powershell 5.1 Minimum
- TrueNAS RESTful API 2.0
- Installing Powershell 7 on Windows
- Installing Powershell 7 on Debian 10
- Installing Powershell 7 on Ubuntu 20.04
Install-Module -Name "TrueNAS-Administration" -Scope CurrentUser -ForceInstall-Module -Name "TrueNAS-Administration" -Scope AllUsers -Force-Scope AllUsers need admin rights.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force- Use
-Scope CurrentUserto persist ExecutionPolicy for Current User. - Use
-Scope LocalMachineto persist ExecutionPolicy for All Users.
Import-Module -Name "TrueNAS-Administration" -ForceGet-Command -Module "TrueNAS-Administration"Find-Module -Name "TrueNAS-Administration"Update-Module -Name "TrueNAS-Administration" -Force- If you have a valid certificate :
$Session = Get-TrueNasSession -Server "truenas" -APIToken "1-xxxxxxxxxxx"- If you don't have a valid certificate, use the parameter
-SkipCertificateCheck:
$Session = Get-TrueNasSession -Server "truenas" -APIToken "1-xxxxxxxxxxx" -SkipCertificateCheckGet-TrueNasInfo -TrueNasSession $SessionGet-TrueNasUser -TrueNasSession $Session- Example 1 :
New-TrueNasUser -TrueNasSession $Session -Credential "userName" -FullName "My New User" `
-MicrosoftAccount -SambaAuthentificationYou will be prompted for the users's password. If you need a non-interactive command, see Example 2.
- Example 2 :
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList @(
"userName", $(ConvertTo-SecureString -String "userPassword" -AsPlainText -Force)
)
New-TrueNasUser -TrueNasSession $Session -Credential $Cred -FullName "My New User" `
-MicrosoftAccount -SambaAuthentificationThis method is less secure because the password is written in clear text in the command line history.
Get-TrueNasGroup -TrueNasSession $SessionNew-TrueNasGroup -TrueNasSession $Session -GroupName "groupName" -SambaGroup