Powershell: Request: DNSServer module for powershell on Linux

Created on 12 Oct 2018  路  4Comments  路  Source: PowerShell/PowerShell

Getting powershell running on Linux is straightforward.

Unfortunately this is based on .NetCore which excludes a lot a important functionality and modules e.g the DNSServer module. It's not installable on Linux using powershell gallery:

PS /home/gmonkey> Install-Module -Name DNSServer -Scope CurrentUser
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'DNSServer'. Try Get-PSRepository to see all available registered module repositories.
At /opt/microsoft/powershell/6/Modules/PowerShellGet/PSModule.psm1:9491 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Is there a workaround to obtain a fully functional PowerShell installation on linux including modules that don't appear in .NetCore (specifically DNSServer) ?

Issue-Discussion

Most helpful comment

@SteveL-MSFT do I understand correctly the recommendation is to connect to a Windows machine to run the DNS cmdlets instead of running them locally on a Linux machine? Agree it would be nice to have this functionality on Linux. We have the same need as @archmangler and are currently connecting over WinRM with our ansible installation using pywinrm to access the DNS cmdlets with Powershell. In ansible it can be as simple as using this, but it's better to avoid WinRM as it has a laundry list of its own problems.

@archmangler FYI I was able to get nsupdate to work at Linux command line a while back with Windows DNS Server. Again, not "Windows-specific" and not supported by MSFT, though.

All 4 comments

The current DNSServer PowerShell module that is in Windows is specific to managing Windows DNS Server and wouldn't work on Linux. If you want to manage Windows DNSServer using the PowerShell module from Linux, you can do this via PowerShell remoting. Using implicit remoting you can run scripts locally on Linux that actually execute remotely on the Windows target (after setting up the PSSession).

If the ask is to manage Linux DNS servers, then that would need to be a completely different module that someone would have to author.

@SteveL-MSFT - Thanks, I've been able to successfully test this from Linux to Windows, with OpenSSH installed on Windows.

However, it just occurred to me that it should also be possible to simply scp a script over to the windows server and execute it using ssh's remote execution capability, as in the following test:

Copy:

scp -v addarecord.ps1 [email protected]:addarecord.ps1

Execute:

(.env) [0101@linuxserver terraform-implementation]$ ssh [email protected] 'powershell ./addarecord.ps1'
[email protected]'s password:

Add-DnsServerResourceRecordA : Cannot connect to CIM server. Access denied
At C:\Users\0101\addarecord.ps1:1 char:1
+ Add-DnsServerResourceRecordA -Name "testserver" -ZoneName
"testzone.com ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : ResourceUnavailable: (PS_DnsServerResourceRecord
   A:String) [Add-DnsServerResourceRecordA], CimJobException
    + FullyQualifiedErrorId : CimJob_BrokenCimSession,Add-DnsServerResourceRec
   ordA

Given this, does it justify the complexity of implicit remoting setup if the above two commands can just be wrapped?

You can always use ssh to execute remote commands without using PowerShell remoting. It's more of a user choice which experience they want.

@SteveL-MSFT do I understand correctly the recommendation is to connect to a Windows machine to run the DNS cmdlets instead of running them locally on a Linux machine? Agree it would be nice to have this functionality on Linux. We have the same need as @archmangler and are currently connecting over WinRM with our ansible installation using pywinrm to access the DNS cmdlets with Powershell. In ansible it can be as simple as using this, but it's better to avoid WinRM as it has a laundry list of its own problems.

@archmangler FYI I was able to get nsupdate to work at Linux command line a while back with Windows DNS Server. Again, not "Windows-specific" and not supported by MSFT, though.

Was this page helpful?
0 / 5 - 0 ratings