Using Powershell ServerManager module on Windows 2016 Server - powershell

I have a module that runs on a Windows 2016 server that requires the ServerManager module. However, ServerManager is not available. There are many examples of installing this for Windows 10 using the Remote Server Admin package but that's only for Windows 10. Hammer Software has a good article on adding features and roles in 2016 but it doesn't say specifically which role will add the ServerManager module to the global environment. There are a gajillion roles and features and I added a few but can't seem to get the ServerManager module into my global environment.
I've read older things (such as this SOF question) that suggest ServerManager is 32 bit and won't autoload for module dependencies. Microsoft still documents it for Server 2012 but doesn't say specifically how to install and use it on Server 2016.
Now I'm totally confused. My module requires ServerManager but how do I get that installed/loaded? If I import the module manually it will work, i.e.:
PS F:\> import-module C:\Windows\sysnative\WindowsPowerShell\v1.0\Modules\ServerManager\ServerManager.psd1
But I need this to load automatically based on my module RequiredModules directive.

To use the Server Manager module, you need to install/enable that RSAT feature. The Server Manager and its PS module are part of that collection.

Related

WARNING: Multiple variants of AWS Tools for PowerShell are currently installed

When I run a powershell script, I get the following warning:
WARNING: Multiple variants of AWS Tools for PowerShell (AWSPowerShell,
AWSPowerShell.NetCore or AWS.Tools) are currently installed. Please
run 'Get-Module -Name
AWSPowerShell,AWSPowerShell.NetCore,AWS.Tools.Common -ListAvailable'
for details. To avoid problems with cmdlet auto-importing, it is
suggested to only install one variant. AWS.Tools is the new
modularized version of AWS Tools for PowerShell, compatible with
PowerShell Core 6+ and Windows Powershell 5.1+ (when .NET Framework
4.7.2+ is installed). AWSPowerShell.NetCore is the monolithic variant that supports all AWS services in a single large module, it is
compatible with PowerShell Core 6+ and Windows Powershell 3+ (when
.NET Framework 4.7.2+ is installed). AWSPowerShell is the legacy
module for older systems which are either running Windows PowerShell 2
or cannot be updated to .NET Framework 4.7.2 (or newer).
Screenshot:
How do I fix the warning? Do I uninstall one or 2 of these modules? Which ones?
Going purely by the error message:
How do I fix the warning?
You ensure that only one of the three listed module (groups) is installed:
Modern, modular group of related modules:
AWS.Tools.*, core module is AWS.Tools.Common, installation-helper module is AWS.Tools.Installer
Legacy modules (monolithic):
AWSPowerShell
AWSPowerShell.NetCore
Do I uninstall one or 2 of these modules? Which ones?
Yes. Which ones to uninstall and thereby implicitly which one to keep depends on your needs and which powershell version you have:
(a) If you're running Windows PowerShell 5.1 and have .NET Framework 4.7.2+ installed, or you're running PowerShell (Core), keep the AWS.Tools.* modules.
(b) If you're still running Windows PowerShell 3 or 4, and have .NET Framework 4.7.2+ or higher installed, keep the AWSPowerShell.NetCore module.
(c) If you're still running Windows PowerShell 2 or a higher version, but cannot install .NET Framework 4.7.2+, keep the legacy AWSPowerShell module.
For instance, to go with (a):
Note
To be safe, run with elevation (as admin), so that removal of modules that were installed in the AllUser scope can be removed.
Any non-installed modules among the specified ones are quietly ignored.
Start a new PowerShell session afterwards (modules already imported in the current session remain in memory, even after uninstallation; however, you can also remove them individually from memory with Remove-Module).
Get-Module -ListAvailable AWSPowerShell, AWSPowerShell.NetCore |
Uninstall-Module -Force

How to install GroupPolicy module for PowerShell?

I just started writing scripts in PowerShell.
The desired script is supposed to create a local GroupPolicyObject (GPO) which will be specified afterwards. Research showed that it could be done with the New-GPO command within the GroupPolicy module for PowerShell. I tried to install the mentioned module but unfortunately nothing I found worked. May I ask for help?
I am using Windows 7 and Powershell 5.1.14409.1005
Error I receive when running example from Microsoft page (New-GPO -Name TestGPO -Comment "This is a test GPO."):
It is actually extremely simple, but the organization of the modules and features has changed many times in the past ten years, Microsoft Docs don't document the up-to-date way anywhere and all articles found online are very old.
Anyway, to install the Powershell Module called GroupPolicy, you need to install the Windows Feature called GPMC (Group Policy Management Console) which includes the mentioned module.
Install-WindowsFeature GPMC
This feature was once a subfeature of the RSAT feature, which is the cause of confusion.
Step 1. Install RSAT from Microsoft site:
https://www.microsoft.com/en-in/download/details.aspx?id=7887
Step 2. Enable Group Policy from Windows Features.
Following link describes the steps in details:
https://www.powershellmagazine.com/2012/05/14/managing-group-policy-with-powershell
Have you installed the RSAT (Remote Server Administration Tools) Group Policy component?

PowerShell Core and AppX package management

I am using PowerShell 6.2 preview at the moment. In my script I am trying to do stuff with Windows 10 apps. To be able to use commands like Get-AppxPackage, I need to import Windows modules from previous PowerShell like so:
Import-Module C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Appx\Appx.psd1 -SkipEditionCheck
Import-Module C:\Windows\system32\WindowsPowerShell\v1.0\Modules\dism\dism.psd1 -SkipEditionCheck
Does PowerShell core has its own modules to work with this? I found Get-Package for example, but that does not give me anything.
Since this is one of the top search results for PowerShell Core Get-AppxPackage, I'm going to take the information from the link provided in the comments and provide an answer, with example.
As LangsGalgEnRad pointed out in the comments, it's easiest just to do this from Windows PowerShell, but ultimately that's just-shy-of-deprecated at this point, with Microsoft stating that there are to be no more fixes or changes other than critical security issues. That said, it's still (afaik) universally available in Windows installations.
But for those of us who want to follow Microsoft's advice to use PowerShell Core, LangsGalgEnRad also points out in the comments the WindowsCompatibility module from Microsoft. Reading the blog post, this seems a bit safer than importing a Windows module (e.g. AppX) from PowerShell Core, since among other things ...
WindowsCompatibility is very careful to not overwrite native PowerShell core commands.
To install from PowerShell Gallery:
Install-Module WindowsCompatibility
Example usage for AppX:
Import-Module WindowsCompatibility
Import-WinModule AppX
Get-AppxPackage

WASP PowerShell 32 bits

I am using WASP successfully with PowerShell 64 bits, but I need to use PowerShell 32 bits cause of OCR MODI.Document.
But my PowerShell x86 is not able to load my WASP module :
See when I am trying to reach WASP module
How is it possible? I've run both with administrator account ...
I've never seen that--I gave rights to everyone, but I can't reach my folder Right for folder WASP
For module to be accessible from both x86 and x64 PS, it should be in:
$Home\Documents\WindowsPowerShell\Modules (%UserProfile%\Documents\WindowsPowerShell\Modules)
$Env:ProgramFiles\WindowsPowerShell\Modules (%ProgramFiles%\WindowsPowerShell\Modules)
You shouldn't install modules in
$PSHome\Modules (%Windir%\System32\WindowsPowerShell\v1.0\Modules)
because
This location is reserved for modules that ship with Windows. Do not
install modules to this location.
See this document: Installing a PowerShell Module.
Here is screenshot of ProcMon, showing that x86 PS doesn't look into the x64 module directory when trying to import module:

WebAdministration module not found

I have installed a WebServer 2008 R2 Core version and I'm trying to configure it to be remotely managed from another server in the domain I need to import the WebAdministration module According to the steps exposed in this article
http://www.iis.net/learn/install/installing-iis-7/install-and-configure-iis-on-server-core
using the Import-module WebAdministration it gives me the specified module 'WebAdministration' was not loaded because no valid module file was found in any module directoryAt line1 char 14. I executed the command Get-Module -ListAvailable and returned 4 module types
BestPractices, BitsTrabsfer, PSDiagnostics and ServeManager
I read the other threads about the issue none of them is consistent and proposes a good solution to that. BTW is there a way to let the server download the requested modules form microsoft repository if not found. Any consistent proposal to solve this will be appreciated
Is the IIS PowerShell Snap-In installed? If not, you can download the 32-Bit version or the 64-Bit version. After you run the MSI (using msiexec /i, since this is core), the snap-in should be registered and can be invoked via import-module or
& "$env:programfiles\IIS\PowerShellSnapin\iisConsole.psc1"
On Windows 7 I installed Web Platform Installer from
https://www.microsoft.com/web/downloads/
On the start menu search for "web" to make the app visible.
Then using Web Platform Installer ... Install IIS: Management Scripts and Tools
Make sure that the IIS is installed and configured properly