PowerShell disappeared or…..

Utilizing the mighty Irwin´s Operation testing in the environment I am building and administrering right now is great success. I have set up a scheduled task that runs every morning and giving me a nice report about the status of the environment and if someone have done reconfigurations or just services being down for any reason.

This week though the scheduled task started to failing.

Apparently someone had done some mistreatment to my environment path so the powershell.exe could not be found any more from CMD thus the scheduled task failing..

Screen Shot 2016-09-02 at 11.11.39

First off I could see that a %path% had snuck into, in CMD ECHO %path% shows all paths so some failure during a PS-script as in powershell %path% does not give love in the same way as the cmd console.

There could be other ways but one easy way is to find another server having the path untouched and removing the %path% from this server and adding the right way to system32 and powershell….

Screen Shot 2016-09-04 at 17.15.47

And then to correctly set the path (if you just use $env:path = $real It will only set it for the current session and not being persistent and in this case it is not enough :

Screen Shot 2016-09-04 at 17.16.32

And once that have been done I could verify that powershell was once again found within the CMD

Screen Shot 2016-09-02 at 11.17.31

PowerShell opensourced woop woop

You might have noticed on twitter and other media that now PowerShell has been released as open source and also available not only for your windows environment but also now for Linux and OS X 🙂

The release is available on Github and go there to get your preferred package for your OS! Read the instructions and be aware that this is the first step and the packages for the non-windows is in alpha!

I have a Mac with OS X and have of course installed it

Screen Shot 2016-08-18 at 16.08.36
Screen Shot 2016-08-18 at 16.09.34

Read some more on Snovers blog post here if you want some more insight in why and how and also some cool demos !

Happy powershelling!!

Explorations within AWS – Setting ACLs on temporary SSD store for SQL

I have been quite busy lately and not had the time to update the blog so much that I wanted but I will try to add some posts during the summer!

In the project I am right now we are setting up environments in Amazons cloud AWS. I have used their images AMI for a SQL Always On cluster that spans over two nodes.

The AMI is preinstalled with SQL and ready for incorporation in an domain and the Enterprise version can be used with the r3.2xlarge r3.4xlarge and r3.8xlarge.

Screen Shot 2016-07-15 at 23.01.47

As you can see each of them have an SSD instance storage that can be used as a temporary volume which suits SQL tempdb perfectly. Just go into the SQL configuration and point its tempdb to the temporary storage! The MSSQL service account is a domain account without administrative rights on the server so that is why I explicit set the rights for the volume…

As the AWS documentations clearly tells us:

An instance store provides temporary block-level storage for your instance. This storage is located on disks that are physically attached to the host computer. Instance store is ideal for temporary storage of information that changes frequently, such as buffers, caches, scratch data, and other temporary content

You can specify instance store volumes for an instance only when you launch it. The data in an instance store persists only during the lifetime of its associated instance. If an instance reboots (intentionally or unintentionally), data in the instance store persists. However, data in the instance store is lost under the following circumstances:

  • The underlying disk drive fails
  • The instance stops
  • The instance terminates

So I created a small powershell script that runs each time the instance boots to set ACL´s on that volume for the SQL to be able to create its tempdb files. No tempdb files = no sql service running….

And this is set up as a powershell job that triggers on the server booting

Happy AWS´ing!

Add Chocolatey to my PackageManagement in Windows 10

I wanted to install the different browsers and also ChefDK on an new Windows 10 client and that with PowerShell. There is of course a way to just run Chocolatey command line but I wanted to use the PackageManagement so I had to add that provider and source so I could just use the Install-Package cmdlet.

I have a Windows 10 1511 with latest patches and I run the following commands to enable the chocolatey repository:

Screen Shot 2016-04-11 at 14.21.17

As you can see, when I enter Find-PackageProvider I find the Chocolatey provider and just run the Install-PackageProvider -Name Chocolatey

Screen Shot 2016-04-11 at 14.25.20

Then I need to open a new PowerShell window and can see that the PackageProvider and PackageSource have the Chocolatey records and thus I can now add software from this,

Screen Shot 2016-04-11 at 14.50.35

First I add Firefox and as you can see my PackageSource is not trusted and I get an warning, that can be configured with the Set-PackageSource -Name chocolatey -Trusted

Screen Shot 2016-04-11 at 14.53.06

Have fun with your package management 🙂

updated AzureRM PowerShell Module with Export of Resource Group

Today the version 1.3.0 of AzureRM module was released and in that there was a new cmdlet Export-AzureRMResourceGroup that can be used on an resource group and get a json file from that!

updating your AzureRM is quite easy with the powershell gallery repository

Screen Shot 2016-03-30 at 12.13.19

And then you can run the Export cmdlet and get the json file from that deployment and start playing in Visual Studio or VS Code 🙂

Screen Shot 2016-03-30 at 11.43.21

Have fun automating and deploying with Azure Resource Manager!

powershell env:PSModulepath duplicate records Winserv 2016 TP4

I was testing some xAzure DSC configuration stuff on my Windows Server 2016 TP4 and noticed that when I was trying to use the resource it said that duplicate modules was found but I could not find any in the powershell module libraries and thus it ought to be something else,

I found the tweet that Ben Gelens sent pointing me to the $env:psmodulepath

Screen Shot 2016-03-23 at 22.02.29

So looking in my psmodulepath I could see that I had two records that was the same and that had to be fixed,

Screen Shot 2016-03-23 at 14.48.58

So to remove the duplicate I first remove both and then add the one again:

Screen Shot 2016-03-23 at 14.49.52

$env:PSModulePath = $env:PSModulePath –replace “;C:\\Program Files\\WindowsPowerShell\\Modules”

Screen Shot 2016-03-23 at 14.52.54

$env:PSModulePath = $env:PSModulePath + “;C:\Program Files\WindowsPowerShell\Modules”

Happy automating 🙂

Download SysCtr 2016 TP4 VHD´s with PowerShell

I have been using and publishing my script for easily download all the VHD´s for evaluating and testing the technical previews of System Center 2016 and now it is time for the TP4! These pre-installed VHD´s make it quite easy to spin up some of the System Center Suite as VM´s on your Hyper-V box within minutes once downloaded.

Here is the script for your convenience and start playing with the new release!

 

 

Managing Azure workloads with Chef and PowerShell DSC at TechDays

pic-devops-kungfu

Last week at TechDays me self and Fredrik Nilsson had a session about managing your workloads in Azure with Chef and PowerShell DSC. Despite the fact that we had the same timeslot as Arwidmark, Nystrom and Ben Armstrong our room was quite full of kung fu interested geeks 😉

Here is the presentation so you can find the links and info:

Screen Shot 2015-10-26 at 10.34.23

TechDaysChefAzure

For you guys that did not have the opportunity to be there, a recording will be available although it is in Swedish…

Playing with automation of OMS agent deployment

I have been playing around with automation of the deployment of OMS agents in my lab environment and wanted to share one way to do it, of course there are others.

I found Adam´s contribution to send files over PS2+ WinRM instead of utilizing a remote share or other deployment of the installation file..  Sometimes you maybe have firewall constraints to take into consideration and then this is a handy way to get that MMAgent over and installed if you have maybe only PowerShell remoting open 🙂

If you already have WMF 5 deployed you can utilize that instead of the Send-File function as it is in the new PowerShell version by default.

Screen Shot 2015-10-13 at 21.40.01

And here is the code:

good luck in deploying those OMS agents!