Installing PowerShell Core in Server Core

In the following Virtual machine scenario, I got one Server Core with Active Directory (Build 16299) and Windows 10 (Build 16299) joined to my new domain. Both Build 16299.
On my Windows client I create a shared folder named “SharedFiles”, where I copy over the latest MSI version of PowerShell Core “PowerShell-6.0.0-win-x64.msi”.

Then, on the Server Core I’m going to create a map drive to my Windows client shared folder to then run the MSI installation from Windows PowerShell Console.

Install Steps

Here are the steps on Server Core Command Prompt:

1. Open Windows PowerShell:

[sourcecode language=”powershell”]
## – Start PowerShell:
PowerShell

[/sourcecode]

2. Map network drive to Windows Client shared folder, then change drive:

[sourcecode language=”powershell”]
## – Map network drive:
New-PSDrive -Name “m” -PSProvider “FileSystem” -Root “\\systemname\sharedfolder”;

## – Change to drive to “m:” and verify the MSI file is there:
m:
dir

[/sourcecode]

3. At the “m:” drive, execute the installation with the following command:

[sourcecode language=”powershell”]
## – Start installing PowerShell Core:
msiexec /i .\PowerShell-6.0.0-win-x64.msi /q

[/sourcecode]

4. As this is a silent installation, so give it a few minutes, then exit to the command prompt
[sourcecode language=”powershell”]
## – type “exit” to get back to the command prompt
exit

## – Change directory to PowerShell Core, and execute pwsh.exe:
cd “C:\Program Files\PowerShell\6.0.0”
pwsh

[/sourcecode]

Setting ExecutionPolicy and Update Help

It has become a routine that after first time openning Powershell, that we need to: 1) set the ExecutionPolicy, and update the help documentation:

So, setting the execution policy, pick the one you need. The most common ones are: “RemoteSigned”, “ByPass”, “AllSigned”, “Unrestricted”.

[sourcecode language=”powershell”]
## – Example setting ExecutionPolicy as “RemoteSigned”
Set-ExecutionPolicy -ExecutionPolicy “RemoteSigned”;

[/sourcecode]

Then, its very important to update the help documentation. I had the tendency to always include to parameter “-Force“:

[sourcecode language=”powershell”]
## – Updating Help documentation:
Update-Help -Force

[/sourcecode]

And, you’re ready to work with PowerShell Core on Server Core.

Oh! How to uninstall PowerShell Core

Let go a little further. Here are the steps to successfully uninstall PowerShell Core on Server Core.
Open Windows PowerShell, make a list of all installed products using Get-WMIObject command:

[sourcecode language=”powershell”]
## – Listing installed products
get-wmiobject Win32_Product `
Select IdentifyingNumber, Name, LocalPackage `
| Format-Table -AutoSize;

[/sourcecode]

This will confirmed PowerShell Core is installed. Pay close attention to the “IdentifyingNumber” property which is really the product GUID.

Now, we can proceed to uninstall PowerShell Core. There are two way to execute a product MSI uninstall:

1. Providing the installation path with filename:

[sourcecode language=”powershell”]
## – Executing Uninstall MSI silently and write to log file: (Using filename)
msiexec.exe /x “c:\filename.msi” /qn /lv “C:\msilogfile.log”

[/sourcecode]

2. Using the IdentifyingNumber (Product GUID) listed when executing the Get-WMIObject:

[sourcecode language=”powershell”]
## – Executing Uninstall MSI silently and write to log file: (Using Product GUID)
msiexec.exe /x ‘{11111111-1111-1111-1111-11111111111X}’dir /qn /lv “C:\msilogfile.log”

[/sourcecode]

Image below doing MSI uninstall using GUID:

Both examples, include the use to write to a log file “C:\msilogfile.log“, along with the necessary switches to uninstall and execute silently. (Above switches are lowercase)

Additional Information

Check the following links on:

1. Installing MSI files with PowerShell: https://kevinmarquette.github.io/2016-10-21-powershell-installing-msi-files/

2. Report or check any issues with PowerShell Core: https://github.com/PowerShell/PowerShell/issues

3. PowerShell Core Reach GA (Generally Available) status: https://blogs.msdn.microsoft.com/powershell/2018/01/10/powershell-core-6-0-generally-available-ga-and-supported/

Be Bold!! Learn PowerShell Core!!

My IDERA’s PowerShell Webcast not only for DBA’s

I decided to compiled all of the webcast I did for IDERA Geek Synch from the last two years(2015 – 2016). Free registration and view the webcast: https://www.idera.com/events/geeksync

iderageeksynch

08/10/2016 – Geek Sync Webcast : Learn the PowerShell Essentials on Error Trapping

Join IDERA and Maximo Trinidad as he walks you through how to find and identify errors in your PowerShell script. Do you want to learn how to trap and document error while running PowerShell scripts? This session will cover the use and how to trap errors in your PowerShell script. We’ll be creating simple script providing some scenarios in trapping errors. At the same time, we are going to end up creating an error report.

https://www.idera.com/resourcecentral/webcasts/sqlserver/geeksync/powershell-error-trapping

06/01/2016 – Geek Sync Webcast : The Essential PowerShell Tools for the Database Administrator

In this session Maximo will be showing some available tools the DBA can use along with PowerShell. We’ll be integrating Visual Studio with PowerShell and at the same time using IDERA’s PowerShellPlus editor. At the end, we’ll build an SSIS package solution to execute our PowerShell script. It will be packed with interesting thing to do as well as help you accomplish your automation tasks.

https://www.idera.com/resourcecentral/webcasts/sqlserver/geeksync/powershell-tools-dba

02/25/2016 – Geek Sync Webcast : The Essentials in Building Basic PowerShell Modules

In this session you’ll learn the basics on how-to build PowerShell Modules. Previously, we’ve learned how to create functions with Maximo. This is the next step to collect and group together all your existing functions to build a module. Most important, Maximo will show you where the modules should be stored and how to load them.

https://www.idera.com/resourcecentral/webcasts/sqlserver/geeksync/basic-powershell-module

11/14/2015 – Geek Sync Webcast : The Essentials to Tackling Basic PowerShell Functions

In this session Maximo will demonstrate the creation of a PowerShell function from a one-liner and/or an existing script file in its basic form. This will show the scripting evolution you’ll experience while building your PowerShell scripting skills. At the same time he will be showing you some existing resources already available at your fingertip.

https://www.idera.com/resourcecentral/webcasts/sqlserver/geeksync/powershell-basics

2015 – Geek Sync Webcast : Creating a SQL Server Database Report with PowerShell

This webinar is a deep dive on how to create a SQL Server report using PowerShell and SMO. At the same time, you will learn how to create and work with PowerShell objects, scriptblocks, formatting properties, and generating output results. We’ll be looking into creating a report to identify database properties irregularities. This will be a good start to help begin documenting your SQL Server on the network.

https://www.idera.com/resourcecentral/webcasts/sqlserver/geeksync/creating-sql-server-db-powershell

2015 – Geek Sync Webcast : PowerShell Essentials using SQL Server SMO

This session will provide the PowerShell essential skills to work with SQL Server Management Objects (well known as SMO). Maximo Trinidad will talk about how-to connect to SQL Server (both Windows and SQL Authentication), working with SMO objects, and showing some PowerShell cmdlets that can assist when building the script(s).

https://www.idera.com/resourcecentral/webcasts/sqlserver/geeksync/powershell-essentials-using-sql-server

It’s never late to learn PowerShell!!

Get a hold of PowerShell (WMF) v5.0 Preview

Windows Management Framework 5.0 May 2014

Again, this version is only available for Windows 8.1 and Windows Server 2012 R2.

On PowerShell  v5.0 Preview just released on May 14th.  This version has no problem with the Azure PowerShell cmdlets installation.  Check out what’s hot in version 5.0 Prewview:  DSC (Desired State Configuration), OneGet and PowerShellGet modules.

Blog: http://blogs.msdn.com/b/powershell/archive/2014/05/14/windows-management-framework-5-0-preview-may-2014-is-now-available.aspx

Download at: http://www.microsoft.com/en-us/download/details.aspx?id=42936

PowerShellV5May2014

Also, Check out the new PowerShell “Script Browser & Script Analyzer 1.2” for ISE and Windows:
http://www.microsoft.com/en-us/download/details.aspx?id=42525

This new ISE AddOn will create two shortcuts: one to open the Script Browser in ISE and the other as an individual Windows application.

Script Browser Icons
Script Browser Icons
Script Browser Windows Application
Script Browser Windows Application
Script Browser in ISE
Script Browser in ISE

Go and get them!

Quick Rundown – Microsoft Azure SQL Database Server and PowerShell

Azure SQL Database 
1. Web and Business editions are no longer available. Now there’s Basic, Standard, and Enterprise editions. (New)
2. There is a limit of 6 SQL Database Servers and up to 150 databases per subscription.
3. Create database from 1 GB up to 500GB of storage.
4. Database Throughput Unit(DTU) Service performance levels available: (New)

  • DTU Service Level:
    1  – Basic
    5 – S1
    25 – S2
    100 – P1
    200 – P2
    800 – P3

AzureSQLdb_DTU

For more information about Azure SQL Database Throughout Units Service, check out Scott Kline and Tobias Ternstrom on this link: http://channel9.msdn.com/Series/Windows-Azure-Storage-SQL-Database-Tutorials/Scott-Klein-Video-02

Quick tips when testing Azure SQL Database Server:
1. There’s no need to specify a storageaccount.
2. Start with “Basic” or “Standard” Service level.
3. Start with  1GB in size for testing.
4. Current Azure Portal version will create random database server names.

Observations on the “Preview” Azure Portal on Azure SQL Datbases:
1. It show the ability to group databases.
2. You can provide a SQL Database Server name (not random).

Upcoming Azure Portal (Preview)

Assign a Group and Name your Database Server
Assign a Group and Name your Database Server

Windows Management Framework 5.0 May 2014

On PowerShell  v5.0 Preview just released on May 14th.  This version has no problem with the Azure PowerShell cmdlets installation.

Blog: http://blogs.msdn.com/b/powershell/archive/2014/05/14/windows-management-framework-5-0-preview-may-2014-is-now-available.aspx

Download at: http://www.microsoft.com/en-us/download/details.aspx?id=42936

Azure PowerShell cmdlets updated

Azure PowerShell cmdlet was updated to version 0.8.2 on 05/12/2014 with 390 commands.AzurePosh_082_05152014

 

 

It’s all about discovering and exploring with PowerShell

Nothing like discovering and exploring what’s already at your fingertip. All you need to get started with PowerShell is already loaded in your system. There are plenty help documentation to keep you busy for awhile.

It’s time to get serious with PowerShell.

Checkout this year TechEd PowerShell session with Don Jones and Jeffrey Snover:

Now, using two known commands: Out-Gridview and Get-help we can search for help information in a flash.  Here I’m providing two custom PowerShell functions that might help you in exploring and learning about PowerShell:

1. Show-HelpPowerShellCommand – Select the module and then which command(s) to display thedocumentation.
2. Show-HelpAboutPowerShellTopic – Select the topic(s) to display the documentation.

Just copy/paste the code into a script file then load them in either PowerShell console or ISE.  To execute the command just type the function name: Show-HelpAboutPowerShellTopic or Show-HelpPowerShellCommand.

[sourcecode language=”powershell”]
function Show-HelpAboutPowerShellTopic
{
<# .SYNOPSIS Function to list all PowerShell About_* topic from the selected list. .DESCRIPTION This function will display in the ‘Out-Gridview’ a list of all PowerShell About_* topics installed in the system. Then, you can select one or multiples topic(s) available. Press the Crtl-Key and select the command(s) you want to get the help documentation. .PARAMETER No Parameter(s) required. .EXAMPLE Show-HelpAboutPowerShellTopics #>

[CmdletBinding()]
Param ()

[Array] $Global:selAbout = $null;
While ($Global:selAbout -eq $null)
{
[Array] $Global:selAbout = $null;
$Global:selAbout = ((Get-Help About_* | Select-Object Name) `
| Out-GridView -PassThru -Title "Listing all PowerShell About_* topics");

if ($Global:selAbout -eq $null) { break };
foreach ($item in $Global:selAbout) { Get-Help $item.Name -ShowWindow };
$Global:selAbout = $null;
};
};
[/sourcecode]

Check the image samples of Show-HelpAboutPowerShellTopic:

Loading Show-HelpAboutPowerShellTopics
Loading Show-HelpAboutPowerShellTopics
Selecting multiple topics
Selecting multiple topics
Viewing results and back to topics listing
Viewing results and back to topics listing

[sourcecode language=”powershell”]
function Show-HelpPowerShellCommand
{
<# .SYNOPSIS Function to list all cmdlets from the selected module(s). .DESCRIPTION This function will display in the ‘Out-Gridview’ a list of all PowerShell modules installed in the system. Then, you can select one of the modules to list all commands available in another ‘Out-Gridview’ window. Press the Crtl-Key and select the command(s) you want to get the help documentation. .PARAMETER No Parameter(s) required. .EXAMPLE Show-HelpPowerShellCommand #>

[CmdletBinding()]
Param ()

[Array] $selItem = $null; [Array] $selCmdlet = $null;
While ($selItem -eq $null)
{
$selItem = get-module -ListAvailable | Select-Object -Unique name, version, path `
| Sort-Object Name | Out-GridView -PassThru;
If ($selItem -eq $null) { break };
[Array] $selCmdlet = $null;
$selCmdlet = (Get-Command -Module $selItem.Name) | Sort-Object Name `
| Out-GridView -PassThru -Title "Module: $($selItem.Name) Total cmdlets: $(((Get-Command -Module $selItem.Name) | Sort-Object Name).count)";
$selItem = $null;
ForEach ($cmd in $selCmdlet) { Get-Help $cmd.Name -ShowWindow; };
If ($selCmdlet -eq $null) { break };
}
};
[/sourcecode]

Loading Show-HelpPowerShellCommand
Loading Show-HelpPowerShellComman
Select one module first
Select one module first
Select cmdlet(s)
Select cmdlet(s)
View help and exit list
View help and exit list

Please notice that these functions will stay active until you click on ‘Cancel’ in either of the select Topics or Module list.

I’m hoping this will make it fun to use.

Latest Azure PowerShell version 0.8.0 has a preview module included

In my previous blog I mention the latest version has two module.  Well, I was wrong!  It’s important that you take the time to read the documentation and pay attention to what’s trending in the social network (such as twitter).  I did notice someone tweet about the new Azure module included in this last released: the “AzureResourceManager“.  And here’s where the fun begin.

There are three modules:

  1. Azure
  2. AzureProfile
  3. AzureResourceManager (Preview)

When executing the “Get-Module -ListAvailable” command you will notice that only 2 will show up: Azure and AzureProfile.

Azure_GetModule_02

This new module is a “PREVIEW“, and the documentation states “The Azure and Azure Resource Management modules are not designed to be used in the same Windows PowerShell session. To make it easy to switch between them, we have added a new cmdlet, Switch-AzureMode.”  Here’s the link to the documentation: http://msdn.microsoft.com/en-us/library/jj554330.aspx

This means that in order to use the new commands from the “AzureResourceManager” you need to run the “Switch-AzureMode” which will prevent you from using the Azure commands such as Get-AzureVM on the same PowerShell session.  Now, keep in mind that you can always open another session to keep working with the Azure module commands.

PowerShell with module Autoload On
PowerShell with module Autoload On

At the same time, If you need to use the command “Import-Module Azure“, you’ll notice that it will give an error telling that it can’t find the module. The trick here is, if you haven’t turned off the PowerShell Module Autoload option, the commands will be available.  Here’s a TechNet link on how to Turn-Off the PowerShell Autoload module (not recommended): http://blogs.technet.com/b/heyscriptingguy/archive/2013/02/20/powertip-turn-off-powershell-module-autoload.aspx

Import-Module Azure Error
Import-Module Azure Error

This is a bug that have been recently reported to the Microsoft Azure PowerShell team.  By default, PowerShell have the Module Autoload “ON” and you will be able to list all the Azure module commands.

PowerShell Autoload Azure commands
PowerShell Autoload Azure commands

So, you can still work with your Azure PowerShell commands and use the “Switch-AzureMode” on another session.

Use the "Switch-AzureMode" to preview the new AzureResourceManager cmdlets

Now you can continue to work with PowerShell Azure command and check out is new (Preview) module AzureResourceManager.

List of the Preview Module AzureResourceManager Cmdlets:Azure_ListPreview_06

Get-AzureLocation
Get-AzureResource
Get-AzureResourceGroup
Get-AzureResourceGroupDeployment
Get-AzureResourceGroupGalleryTemplate
Get-AzureResourceGroupLog
New-AzureResource
New-AzureResourceGroup
New-AzureResourceGroupDeployment
Remove-AzureResource
Remove-AzureResourceGroup
Save-AzureResourceGroupGalleryTemplate
Set-AzureResource
Stop-AzureResourceGroupDeployment
Test-AzureResourceGroupTemplate

Happy PowerShelling!

IT Palooza South Florida Great Success – PowerShell Rules!

Great event on 12/12/2013 in South Florida with most IT Community User Groups showcasing their stuff. It was full of people and friends.

Florida PowerShell User Group represented!
Florida PowerShell User Group represented!
List of community IT User Groups
List of community IT User Groups
At Nova University, Davie FL.
At Nova Southeastern University, Davie FL.

Thanks to Nova Southeastern University and organizers (specially Alex Funkhouser) for having me as a speaker present a little bit of PowerShell.

Me with Microsoft IT Pro Evangelist Blain Barton.
Me with Microsoft IT Pro Evangelist Blain Barton.
Sharing table with Microsoft.
Sharing table with Microsoft.

Also, thanks to all who attended my session on “Integrating PowerShell in SSIS Script Task“. It was a great to pass some knowledge and see everyone participating.

Thank You!

PowerShell Community Tools loaded in SQL Data Tools BI.
PowerShell Community Tools loaded in SQL Data Tools BI.

Here’s the presentation (fully loaded):

This presentation contains LOTS of goodies in it.

1. It contains a .NET console solution.
2. SSIS solution (no-NONsense).
3. Sample PowerShell scripts
4. Sample .NET code both C# and VB.NET (code snippets)

All this material so you can study it. Take your time and make it your own.

This folder (C:\TempSSIS) need to be copied to the root of the C:\ drive.

Things to pay attention too. Here’s some other important updates for Visual Studio 2012:
1. Visual Studio 2012 Team Explorer 8/2/2012 – http://www.microsoft.com/en-us/download/details.aspx?id=30656
2. Visual Studio 2012 Update 4 11/12/2013 – http://www.microsoft.com/en-us/download/details.aspx?id=39305

Don’t forget to Team Foundation Online (free up to 5 users): http://www.visualstudio.com/products/visual-studio-online-overview-vs

Plus two PowerShell community tools you should consider using with Visual Studio:
1. “PowerShell Tools for Visual Studio” by Adam Driscoll (PowerShell MVP) – http://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597
2. “StudioShell” by Christopher Beefarino (PowerShell MVP) – http://studioshell.codeplex.com/

Keep learning PowerShell!

Great PowerShell sessions at SQLSaturday SoFla on June 29th 2013

Yes! On Saturday June 29th, I’ll be presenting two interesting PowerShell sessions:

1. DBA Track – PowerShell Working with XML

2. SSIS Track – Integrating PowerShell in a ScriptTask component

These session come full of demos and reference information.  The important one is the  “SSIS – Integrating PowerShell in a ScriptTask component” which help you to include your already existing PowerShell script file in a SSIS solution using SQL Data Tools 2012.

I’ll be show existing exciting tools such as SAPIEN Technologies:

1. PrimalXML 2012

2. PrimalSQL 2012

3. PrimalScript 2012

4. PowerShell Studio 2012

5. Open Source .NET development tool – SharpDevelop ( and you’ll see WHY!)

Also, I will be giving away some exciting stuff you don’t want to miss.

Please come and join us in this Great SQLSaturday event.  Here’s my presentation for both sessions.

PowerShell v3 fun with Get-Help and Out-GridView

PowerShell comes loaded with help documentation, and in PowerShell V3 this documentation is updated via the internet.  Now, lets have some fun with the Get-help and the updated Out-Gridview command.

The Out-Gridview cmdlet have a ‘-passthru‘ parameter that gives you the ability to select items from the popup window and the pass these values to the next command.  This is neat!!

Copy/paste the code below into your PS console to load the “Get-HelpTopics“:

[sourcecode language=”powershell”]
Function Get-HelpTopics{
## – Have fun using PassThru switch to select item(s): (PowerShell V3 feature)
$HelpNames = (GET-HELP About_*) | select name;
foreach($i in ($HelpNames | Select name | Out-GridView -PassThru))
{
$i | Select @{Label = ‘Topic Selected’; Expression = {$_.Name}};
Get-Help $i.Name -ShowWindow;
}
};
[/sourcecode]

Then, to execute type “Get-HelpTopics” and the list of topics will be displayed in a popup window.

Hold the ‘Ctrl’ key to select/mark the topics you want to read, then click the ‘OK’ button when done.

As you can see you will get a series of popup windows documentation you can move around and read about PowerShell. At the same time you are seeing how helpful is the use of the ‘-passthru‘ parameter in the ‘Out-Gridview’, and the ‘-ShowWindow‘ parameter in the ‘Get-help’.

This is a fun way to start learning PowerShell.
** This is a Windows PowerShell V3 script **