Powershell - Plugin

Recommended Posts

Hello All, 


I have no experience with Unraid plugins,  I would like some help with someone to create a Powershell plugin to allow the use Powershell Remoting via SSH.


I am able to install it locally, BUT after a reboot, the application goes away.

Any help, or direction how to create a plugin, would be greatly appreciated.  


FYI, this would be perfect for an addition to NerdTools plugin.




## SOURCE https://docs.microsoft.com/en-us/powershell/scripting/install/install-other-linux?view=powershell-7.2

# Download the powershell '.tar.gz' archive
curl -L -o /tmp/powershell.tar.gz https://github.com/PowerShell/PowerShell/releases/download/v7.2.2/powershell-7.2.2-linux-x64.tar.gz

# Create the target folder where powershell will be placed
sudo mkdir -p /opt/microsoft/powershell/7

# Expand powershell to the target folder
sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/7

# Set execute permissions
sudo chmod +x /opt/microsoft/powershell/7/pwsh

# Create the symbolic link that points to pwsh
sudo ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh



At shell, type 




Remoting Customization


- Create SSH file

nano /boot/config/ssh/sshd_config


- Content:


PasswordAuthentication yes
PubkeyAuthentication yes
Subsystem powershell /usr/bin/pwsh -sshs -NoLogo


- Save file,

- Restart SSH

 /etc/rc.d/rc.sshd restart






$session = New-PSSession -HostName $hostname -UserName root

Id Name            Transport ComputerName    ComputerType    State         ConfigurationName     Availability
 -- ----            --------- ------------    ------------    -----         -----------------     ------------
  4 Runspace3       SSH       HOSTNAME     RemoteMachine   Opened        DefaultShell             Available
Invoke-Command -Session $session -ScriptBlock {hostname}



With this, I would like to create a powershell module to control different aspects of the Unraid server.


















Link to comment
16 hours ago, Gaston Paquette said:


I am able to install it locally, BUT after a reboot, the application goes away.

Unraid runs from RAM. The only persistent media is mounted at /boot (flash drive, don't write things there unnecessarily, people get upset if your plugin prematurely wears out their licensed flash stick), and any mounted pools and array drives in /mnt.


Any modifications to the OS have to be reapplied on reboot.


I suggest doing research on current plugins and how they operate, so you can see what is best practice when dealing with the somewhat unique Unraid ecosystem.

Link to comment
  • 11 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.