Among many of the things that we’ve seen coming out of the Microsoft camp in the last couple of years, is the opening up of many of the platforms that were traditionally very closed. We are talking about the introduction of mainstream Microsoft properties in non-Microsoft platforms, not least of which is the latest with the PowerShell on multiple operating systems.
Apple is fairly popular among the desktop and laptop operating system environments for many folks who also administer Microsoft environments. As someone who has always been an advocate for open source, I used to run Linux as my primary laptop operating system and use VMware Workstation to run a Windows Desktop to do any admin work there. We also have plenty of RDP options for remote desktop access to our Windows-based servers.
Enter PowerShell…Cross-Platform Alpha Edition
PowerShell Core supports macOS 10.12 and higher. I just wanted to let you know and it’s very easy of course you need to know what are you are doing. I don’t know how many Zambian IT folks run macOS. I have been on macOS when it was OS X and deserve a couple of knowledge around the system.
PowerShell Core is a cross-platform (Windows, Linux, and macOS) automation and configuration tool/framework that works well with your existing tools and is optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models. Here’s another problem to solve with PowerShell: Find the IP address of a remote computer. Sounds simple enough. However, as with many tasks in the world of PowerShell, there are several ways to. This article describes the use of PowerShell scripting on Mac and Linux. “PowerShell” refers to both the command-line shell and scripting language designed system administration. PowerShell is an object-centered “management engine” that can be hosted in an application program. CMD in Windows; PowerShell ISE (from Microsoft) PowerGUI.
NOTE: This is featuring an alpha version of the platform, so obviously, you will want to tread carefully on how much you rely on it. That said, I’m all in on the version, and have tested it without having any serious issues.
To get the code for Mac, go to the GitHub site for the PowerShell project here: https://github.com/PowerShell/PowerShell
The download links are located a little bit down the page within the Readme:
Click the version that matches your OS, which is going to be macOS 10.11 for my example. the .pkg file will download to your default location. Mine is in my Downloads folder, where I will find the file and double-click to launch the installer:
Select your hard drive name that matches the one in your system and click the Install button:
You will be prompted for your credentials because it is writing to the filesystem where you will add it to the /usr/local/bin folder:
And with that, you’re done the install:
Launch a Terminal session, and you can simply type powershell as a command now to launch the shell environment.
After launching, you can type any PowerShell command in the shell. They aren’t case-sensitive, but if you use the autocomplete by using the Tab key when a partial command is typed, the autocomplete will expand to the available command.
For example, if you type get-h and use the Tab key, you will see the command change to Get-H and also it will show you the available commands underneath that begin with Get-H.
Let’s try the Get-History command to see what it shows. My example has a few things in the history because I tested it out:
We also have all of the help files locally on the system. You can get the help for any command by type Get-Help and then the name of the command. If we want to see what the help file and parameters are for the Get-Runspace command, just type Get-Help Get-Runspace to see the results:
There you have it! You are now running a Microsoft scripting environment on an Apple device. Who would have thought that seeing Bill Gates’ face looming over the 1997 Macworld conference in Boston, that we would see the true merging of platforms like we are seeing here.
Go forth and PowerShell all the things!
As a mobile developer 90% of the time I work on a mac. Visual Studio for Mac is an awesome tool to create Xamarin mobile apps. More than not mobile apps are using services. You can use .NET Core to create APIs but deploying them isn't so easy on a mac. Sure you can use the Azure CLI, but if you are working with mixed teams Powershell seems to be king to deploy towards Azure.
About a year ago Microsoft made Powershell available for MacOs. But that doesn't mean you can use all of the Modules that are available. Until a few days ago you couldn't use AzureRM. Now that the AzureRM.NetCore is no longer in preview, it's time to explain how you can use the power of Powershell and AzureRM on your mac.
Installing Powershell
As I couldn't get the AzureRM modules working on an older version you need to make sure you run the latest version of Powershell for Mac.
You can download a .pkg package from https://github.com/PowerShell/PowerShell.
Installing is as simple as any other package. Windows media player for mac 2019. Just follow the wizard.
You can download a .pkg package from https://github.com/PowerShell/PowerShell.
Installing is as simple as any other package. Windows media player for mac 2019. Just follow the wizard.
After installing the package you can verify the version of Powershell by opening a terminal window and start Powershell.
The version I have is v6.0.0-beta4. I couldn't make AzureRM work with version v6.0.0-beta3 so make sure you have at least version v6.0.0-beta4.
Installing AzureRM modules
Before installing modules you'll need to know in which directory you want to store your modules.
Open a Powershell and verify the path where you can store your modules
Open a Powershell and verify the path where you can store your modules
My path looks like:
![Powershell Powershell](/uploads/1/3/4/1/134111192/132183193.png)
I will store my modules in:
To install the AzureRM modules you'll need to open up a terminal and login as a root user. The instructions come from: https://www.powershellgallery.com/packages/AzureRM.Netcore/0.9.1
The path provided in the latest command corresponds with the path you found via $env:PSModulePath
Using the AzureRM modules
You can close the admin/root session and start a session as normal user.
Verify that the AzureRM modules are available
If you try to execute the Login-AzureRmAccount login command to login on Azure and start executing your scripts.
What if the AzureRM modules are not available?
When starting a Powershell session, not all modules are loaded to save memory. Depending on how you installed or stored the modules they won't be available by default.
Powershell For Mac Github
So if the Login-AwureRmAccount is not available for you, you can auto load the AzureRm modules when starting a new Powershell session. You can do that by changing your profile.
Search for your profile: https://renewarch501.weebly.com/play-station-emulator-for-mac.html.
My profile is located on:
Powershell For Mac Os X
If it doesn't exist you can simply create it.
You can simply import a module by adding 'Import-Module MyModuleName' in the file. Because AzureRM has multiple modules you can add them in one command
Powershell For Mac Ise
Authenticate to Azure via Powershell
Now you can authenticate via Powershell so can start executing the powershell scripts in your Xamarin solution.
Now open up a browser and go to https://aka.ms/devicelogin, provide the code that you got in your powershell session and you're good to go!
Conclusion
Microsoft made powershell and the AzureRM Modules available on MacOS. It will allow us to automate our backend deploys for our Xamarin mobile apps without switching to Windows.