Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit focus mode

PowerShell on Nano Server

  • 2020-08-07
Feedback

In this article

Applies to: Windows Server 2016

Important

On October 9, 2018, support for theNano Server installation option ended. Starting in Windows Server, version 1709, Nano Server is available only as acontainer base OS image. Check outChanges to Nano Server to learn what this means.

PowerShell Editions

Starting with version 5.1, PowerShell is available in different editions which denote varying feature sets and platform compatibility.

  • Desktop Edition: Built on .NET Framework and provides compatibility with scripts and modules targeting versions of PowerShell running on full footprint editions of Windows such as Server Core and Windows Desktop.
  • Core Edition: Built on .NET Core and provides compatibility with scripts and modules targeting versions of PowerShell running on reduced footprint editions of Windows such as Nano Server and Windows IoT.

The running edition of PowerShell is shown in the PSEdition property of $PSVersionTable.

$PSVersionTableName                           Value----                           -----PSVersion                      5.1.14300.1000PSEdition                      DesktopPSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}CLRVersion                     4.0.30319.42000BuildVersion                   10.0.14300.1000WSManStackVersion              3.0PSRemotingProtocolVersion      2.3SerializationVersion           1.1.0.1

Module authors can declare their modules to be compatible with one or more PowerShell editions using the CompatiblePSEditions module manifest key. This key is only supported on PowerShell 5.1 or later.

New-ModuleManifest -Path .\TestModuleWithEdition.psd1 -CompatiblePSEditions Desktop,Core -PowerShellVersion 5.1$moduleInfo = Test-ModuleManifest -Path \TestModuleWithEdition.psd1$moduleInfo.CompatiblePSEditionsDesktopCore$moduleInfo | Get-Member CompatiblePSEditions   TypeName: System.Management.Automation.PSModuleInfoName                 MemberType Definition----                 ---------- ----------CompatiblePSEditions Property   System.Collections.Generic.IEnumerable[string] CompatiblePSEditions {get;}

When getting a list of available modules, you can filter the list by PowerShell edition.

Get-Module -ListAvailable | ? CompatiblePSEditions -Contains Desktop    Directory: C:\Program Files\WindowsPowerShell\ModulesModuleType Version    Name                                ExportedCommands---------- -------    ----                                ----------------Manifest   1.0        ModuleWithPSEditionsGet-Module -ListAvailable | ? CompatiblePSEditions -Contains Core | % CompatiblePSEditionsDesktopCore

Script authors can prevent a script from executing unless it is run on a compatible edition of PowerShell using the PSEdition parameter on a #requires statement.

Set-Content C:\script.ps1 -Value #requires -PSEdition CoreGet-Process -Name PowerShellGet-Content C:\script.ps1#requires -PSEdition CoreGet-Process -Name PowerShellC:\script.ps1C:\script.ps1 : The script 'script.ps1' cannot be run because it contained a #requires statement for PowerShell editions 'Core'. The edition of PowerShell that is required by the script does not match the currently running PowerShell Desktop edition.At line:1 char:1+ C:\script.ps1+ ~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (script.ps1:String) [], RuntimeException    + FullyQualifiedErrorId : ScriptRequiresUnmatchedPSEdition

Differences in PowerShell on Nano Server

Nano Server includes PowerShell Core by default in all Nano Server installations. PowerShell Core is a reduced footprint edition of PowerShell that is built on .NET Core and runs on reduced footprint editions of Windows, such as Nano Server and Windows IoT Core. PowerShell Core functions in the same way as other editions of PowerShell, such as Windows PowerShell running on Windows Server 2016. However, the reduced footprint of Nano Server means that not all PowerShell features from Windows Server 2016 are available in PowerShell Core on Nano Server.

Windows PowerShell features not available in Nano Server

  • ADSI, ADO, and WMI type adapters
  • Enable-PSRemoting, Disable-PSRemoting (PowerShell remoting is enabled by default; see the Using Windows PowerShell Remoting section ofInstall Nano Server).
  • Scheduled jobs and PSScheduledJob module
  • Computer cmdlets for joining a domain { Add | Remove } (for different methods to join Nano Server to a domain, see the Joining Nano Server to a domain section ofInstall Nano Server).
  • Reset-ComputerMachinePassword, Test-ComputerSecureChannel
  • Profiles (you can add a startup script for incoming remote connections withSet-PSSessionConfiguration)
  • Clipboard cmdlets
  • EventLog cmdlets { Clear | Get | Limit | New | Remove | Show | Write } (use the New-WinEvent and Get-WinEvent cmdlets instead).
  • Get-PfxCertificate cmdlet
  • TraceSource cmdlets { Get | Set }
  • Counter cmdlets { Get | Export | Import }
  • Some web-related cmdlets { New-WebServiceProxy, Send-MailMessage, ConvertTo-Html }
  • Logging and tracing using PSDiagnostics module
  • Get-HotFix (to obtain and manage updates on Nano Server, seeManage Nano Server).
  • Implicit remoting cmdlets { Export-PSSession | Import-PSSession }
  • New-PSTransportOption
  • PowerShell transactions and Transaction cmdlets { Complete | Get | Start | Undo | Use }
  • PowerShell Workflow infrastructure, modules, and cmdlets
  • Out-Printer
  • Update-List
  • WMI v1 cmdlets: Get-WmiObject, Invoke-WmiMethod, Register-WmiEvent, Remove-WmiObject, Set-WmiInstance (use CimCmdlets module instead.)

Using Windows PowerShell Desired State Configuration with Nano Server

You can manage Nano Server as target nodes with Windows PowerShell Desired State Configuration (DSC). Currently, you can manage nodes running Nano Server with DSC in push mode only. Not all DSC features function with Nano Server.

For full details, seeUsing DSC on Nano Server.


Feedback

Was this page helpful?

YesNo

In this article

Was this page helpful?

YesNo