Disable proxy settings at system level

Today I was facing some issues with the proxy server at the company I was working for.
It seemed that a rule was applied that made all servers connect outbound trough a proxy, instead of only the desktops as provided.

In an attempt to quickly resolve this issue, I quickly searched the internet.
I found that its rather easy to find how to disable the proxy settings using GPO, or at a user level. However it was not that easy to find how to disable this at a system level.

It seems that there are 2 registry keys that need to be created (or modified) to do this.
These registry keys are located at HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings

Step 1, disable the user based proxy settings:
In the HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings there is a DWORD called ProxySettingsPerUser, if this is set to 0 it will be disabled and system wide settings are used. Put it back to 1 or remove this key entirely to enable user based proxy settings again.

Step 2, disable the automatic detect proxy settings checkbox.
In the HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings there is a DWORD called EnableAutoProxyResultCache, set it to 0 and it will be disabled.

Here is a simple script you can use to inject these settings into the registry directly.

$regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings"
$null = New-ItemProperty -Path $regPath -Name 'ProxySettingsPerUser' -Value 0 -PropertyType DWORD -Force
$null = New-ItemProperty -Path $regPath -Name 'EnableAutoProxyResultCache' -Value 0 -PropertyType DWORD -Force

~Danny

Creating goals, mastering challenges, and realising dreams.

Somebody once told me, that to live your life to the fullest, you have to chase your dreams.
This is exactly what I have been working on throughout my entire carrier, although the biggest step in this might be today.

When I was only 3 years old, it was my eldest brother that introduced me with computers. To be exact it was the Commodore 64. I will never forget this moment, especially spending hours copying games from my receiver to my disks.
Ever since that moment, computers hypnotized me, I love them, and I made it my hobby to learn everything I wanted to know about them. My goal was to do ‘tricks’ with them, do the things you weren’t supposed to do. Or to just break the software and try to fix it again (hopefully learn something additional this way).

Years had passed when I became older, and my goals had changed. Somebody asked me what I would like to become when I got older. I could not put my finger on it what I exactly wanted to do, but it had to be something with computers, I wanted to make a living out of my hobby.
Eventually I switched my education to study ICT at the Nova Collega in Hoofddorp, and after this I eventually found my first job as helpdesk employee for SNT/Wanadoo.

Shortly after this I found my next goal, the old fashioned IT we’re been working on, that had to be an better way. My new goal was to automate every action I had to do at-least 3 times in a row manually. This did not make all managers happy at the time, since automating would cost precious time where they did not see direct result, so I made this my new hobby.
Finally years later after teaching myself, Delphi, Visual Basic and Java, a new language started becoming a big player on the market: PowerShell.
It was during this period I had to do a lot of daily manual actions for Exchange at a customer, and I quickly noticed that writing a few minor scripts made my day a hell of a lot easier.
After I showed this to management they asked me to do this more often, and usually for deployments, or virtual servers.

Eventually I got in touch with automating VMware, and later on Hyper-V. I changed my goals again. I wanted to do more with virtualization, and eventually more with cloud technologies.
Everybody talked about the ‘Cloud’ but what did that really mean?. I did not exactly know it yet at that time but I did know I wanted to lean a lot about it, and share it with the people around me.
I started combining my new passion with cloud technologies with the scripting knowledge I had been working on. I began to automate deployments, write additional code to manage Hyper-V environments in an easier way, and eventually wrote scripts to deploy ‘Roles’ to servers. Because be honest, how many people want an empty server? They want to have specific applications or functions, and perhaps the most important, they wanted every machine to be exactly the same after a deployment (outside of specifications).

Again I learned quite a lot, and technologies changed big time these last few years.
This made me again review my goals. I wanted to share all this knowledge with more people. I loved talking about the new stuff I had been working on, how you could use it in your daily job, and how to simplify managing your environments.
I started blogging, giving presentations at customers, and at some events. But I also started sharing code back to the community on Git-Hub. This is where I had landed un until now, and what I am still doing on a day to day basis.

However, about a year ago a new goal started growing in me. I loved working with automation, new Microsoft cloud solutions, and sharing stuff. But I wanted to do more.
Everywhere I looked around me, when big players and sourcing companies were recruiting and delivering generic systems engineers, or generic automation engineers, nobody placed themselves on the market as ‘the experts’ for PowerShell or Cloud Automation. It became my dream to see if I could fill this gap.

At about this same time, I was placed at a customer together with my good friend and colleague Jeff Wouters. We roughly had about the same idea’s, and eventually we sat together to discuss our ideals and goals, and see if we could realise them: create a company that is fully specialised in Cloud & PowerShell automation. This is where the new Methos was born.

Since Jeff and I are both very community related, it probably won’t surprise you that we are trying to make a difference when it comes to communication between colleagues in the field.
You hire an expert? You don’t only receive the expertise of this individual, but the expertise of the whole Methos group. We believe that nobody knows everything, and you know more with many.
If there is enough contact between the colleagues, people can learn and grow with each other’s expertise’s. Next to this we will encourage people to go to community events around their own expertise’s, and will invite customers to internal master classes on different topics.

The next few years, we will be focussing us on our new dream, and to build on Methos. We will do more than our best to make this a successfully company, and The cloud and datacentre experts in the Netherlands.

Create custom Webworkers in Windows Azure Pack Websites

Today a customer came to me with the question if it would be possible to create your own Webworkers in Windows Azure Pack websites.
The reason for doing this is because they want customers within 1 subscription to be able to have 1 website in a “small” scale, and for example another in a “medium” scale.

With the default instances available this is not possible.
When you install Windows Azure Pack websites you get 2 compute modes: Shared, and Dedicated. You get 3 SKU modes: Free, Shared and Standard.
And these SKU modes have one or multiple worker Tiers.

Free: Shared
Shared: Shared
Standard: Small, Medium and Large

So to be able to reach this goal we need to create dedicated SKU’s for new the existing tiers, or new tiers in new dedicated SKU’s.
After starting to look for some documentation I found there was not much available describing this, however when I started looking for commandlets I found the following:

get-command *sku* -Module websitesdev

CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Get-WebSitesSku 1.0 Websitesdev
Cmdlet New-WebSitesSku 1.0 Websitesdev
Cmdlet Remove-WebSitesSku 1.0 Websitesdev
Cmdlet Set-WebSitesSku 1.0 Websitesdev
get-command *tier* -Module websitesdev

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-WebSitesWorkerTier                             1.0        Websitesdev
Cmdlet          New-WebSitesWorkerTier                             1.0        Websitesdev
Cmdlet          Remove-WebSitesWorkerTier                          1.0        Websitesdev
Cmdlet          Set-WebSitesWorkerTier                             1.0        Websitesdev

After this, the next few steps were easy to create a new Workertier, and a new SKU.

New-WebSitesWorkerTier -Name "Custom-Small" -ComputeMode "Dedicated" -NumberOfCores '1' -description "Custom Small Tier" -MemorySize '2048'
New-WebSitesSku -SkuName 'Custom' -ComputeMode 'Dedicated' -WorkerTiers 'Custom-Small'

CustomWebworker

Now I was able to add this new worker into my websites cloud, and use it in my Windows Azure Pack portal!

New SQLServer DSC Resource cSQLServer

Today we have released a new SQL Server DSC Resource that has been created by merging the already existing xSQLServer and xSqlPs resources and adding new functionality like:

– SQL Always-On (with domain credentials)
– SQL Always-On between 2 Clusters
– SQL File streaming
– SQL Always-On with Listener

For more information please check the source at:

cSQLServer:       https://github.com/Solvinity/cSQLServer
cFailoverCluster: https://github.com/Solvinity/cFailoverCluster
Demo Video:       https://youtu.be/l8KwLUtXNB8

A more in depth article will be published early January!

-Danny

Merry X-mas and a Happy New Year!

Its that time of year already, where the holiday celebrations start and everybody sends each other the bests of wishes in cards. I usually do this the traditional way too, but I wanted to do it slightly different this year 😉

https://github.com/DdenBraver/Xmas-Tree

Have a good year!

-Danny

Activate Windows VMs using Powershell Direct

# This code requires Windows 10 professional/Enterprise or Windows Server 2016
$vmname = read-host "VMName"
$key = read-host "Windows Key"
 
Invoke-Command -VMName $vmname -ScriptBlock {
param($key)
Write-Verbose -Message "Attempting to inject Windows key: $key"
Cscript.exe $env:SystemRoot\System32\slmgr.vbs -ipk $key
Write-Verbose -Message "Attempting to activate Windows key"
Cscript.exe $env:SystemRoot\System32\slmgr.vbs -ato
} -ArgumentList $key

 

DSC Module: cManageCertificates

I just bumped into the issue where I needed to import a certificate to a server before I could use it in a DSC resource. Since there was no DSC Resource available yet to import or remove certificates from a certain store from a computer I had to create one myself.

cManageCertificates

The result can be found here: https://github.com/DdenBraver/cManageCertificates

This resource is pretty simple, and it uses the powershell cmdlet Import-PfxCertificate to import a certificate, and the Remove-Item “Cert:\Storetype\Store\Thumbprint” to remove a certificate if required.

Using Powershell Packagemanager (OneGet) basics

One of the new great features of WMF5, included in Windows 10 RTM is Powershell Packagemanager (previously called OneGet).

I will not go into the details on how it works or what it is (that you can find here!) I do want to show you how you can use it to simply install some packages from the powershell gallery, or from chocolatey which is basically a community based package source that already includes alot of applications and tools.

Lets take a look at the basic command sets:
Find-Package: find the package you are looking for in the registered package sources in powershell packagemanager
Get-Package: finds the packages on your system that have been installed using powershell packagemanager
Install-Package: installs a package on your system using powershell packagemanager
Uninstall-Package: removes a package from your system that was installed using powershell packagemanager

When you first kick off find-package you may get the request that the package provider nuget has not been installed and needs to be downloaded and installed.

The provider 'nuget v2.8.5.127' is not installed.
nuget may be manually downloaded from https://oneget.org/nuget-anycpu-2.8.5.127.exe and installed.
Would you like PackageManagement to automatically download and install 'nuget' now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

If you select Yes, you will now (by default) get a list of available packages -from the powershell gallery only-.

Lets now install the chocolatey package provider so that we can use PowerShell Packagemanager to install available community packages.

PS C:\Users\Administrator> get-packageprovider -name chocolatey

The provider 'chocolatey v2.8.5.130' is not installed.
chocolatey may be manually downloaded from https://oneget.org/ChocolateyPrototype-2.8.5.130.exe and installed.
Would you like PackageManagement to automatically download and install 'chocolatey' now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"):

If you now once again do a find-package you will suddenly see alot of additional packages that are available from the source ‘chocolatey’. Please be aware however that not all of these packages can be trusted (please read the chocolatey FAQ)

You can install simply the packages by using the install-package, or pipe the install package behind the find-package to also install the dependencies (if any). For example:

Install-package -Name 'GoogleChrome'
Find-Package 'GoogleChrome' -IncludeDependencies | Install-Package

After the software has been installed you can review the installed software by using get-package

Get-Package -Name 'GoogleChrome'

Name                           Version          Source           Summary
----                           -------          ------           -------
GoogleChrome                   45.0.2454.101    C:\Chocolatey...

Here is an example script that you can use for installing some software to your local desktop with powershell packagemanager: oneget_example.ps1

I hope you can enjoy this new functionality as much as myself. This new functionality could greatly help with package deployment and management in the future. You could for example set up your own package repository and deploy your own internal packages using Nuget Server.

Using Powershell to get your server’s uptime!

I have always missed the option in windows to just easily see the uptime from a server.

Ofcourse we have the uptime.exe available from Microsoft, but I wanted to have something available directly from powershell.

For starters we could get the last bootuptime from WMI with the following query

(Get-WmiObject -Class win32_operatingsystem).lastbootuptime
20151005150834.490241+120

Since this is not really in a nice format, lets change it into something we can read

[System.Management.ManagementDateTimeconverter]::ToDateTime((Get-WmiObject -Class win32_operatingsystem).lastbootuptime)
Tuesday, October 6, 2015 10:37:14 AM

Now that we have the bootup time/date in a readable format we can substract this date from our current time/date to get our actual uptime.

((Get-Date)-([System.Management.ManagementDateTimeconverter]::ToDateTime((Get-WmiObject -Class win32_operatingsystem).lastbootuptime)))

Days              : 0
Hours             : 0
Minutes           : 16
Seconds           : 8
Milliseconds      : 736
Ticks             : 9687365862
TotalDays         : 0.0112122290069444
TotalHours        : 0.269093496166667
TotalMinutes      : 16.14560977
TotalSeconds      : 968.7365862
TotalMilliseconds : 968736.5862

And there you go, you can now see the uptime for your server. I took this along a bit and created a powershell function to make it more usable for everyone in the company.

Function Get-Uptime 
{
    <#
            .SYNOPSIS
            Get uptime for Server(s)
            .DESCRIPTION
            This script will provide you the uptime for your servers in easy format
            .PARAMETER Servers
            One or multiple servers
            .EXAMPLE
            Get-Uptime -Server "computername"
            Request the uptime for a server
    #>
    [CmdletBinding(SupportsShouldProcess = $true)]

    param(
        [parameter(Mandatory = $true, HelpMessage = 'Please enter a computername.')]
        [alias('Computernames','Computername','Server','Computer')]
        [string[]]$servers
    )

    ForEach ($server in $servers) 
    {
        Write-Verbose -Message "Retrieving information from $server"
        $uptime = ((Get-Date )-([System.Management.ManagementDateTimeconverter]::ToDateTime((Get-WmiObject -Class win32_operatingsystem -ComputerName $server -ErrorAction SilentlyContinue ).lastbootuptime)))
        $server | Select-Object -Property @{
            Name       = 'Computername'
            Expression = {
                $server
            }
        }, 
        @{
            Name       = 'Days'
            Expression = {
                $uptime.Days
            }
        }, 
        @{
            Name       = 'Hours'
            Expression = {
                $uptime.Hours
            }
        }, 
        @{
            Name       = 'Minutes'
            Expression = {
                $uptime.Minutes
            }
        }, 
        @{
            Name       = 'Seconds'
            Expression = {
                $uptime.Seconds
            }
        }, 
        @{
            Name       = 'Milliseconds'
            Expression = {
                $uptime.Milliseconds
            }
        }
    }
}

Now you only need to type Get-Uptime “servername” to get the uptime for the server you wish 🙂

PS C:\> get-uptime localhost | FT

Computername Days Hours Minutes Seconds Milliseconds
------------ ---- ----- ------- ------- ------------
localhost       0    19      49      32          478

 

Zipping your DSC Resources

When you are setting up a DSC Pull scenario, you will have to zip your DSC Resources in a correct format and by using proper tooling.

At first you need to zip your primary directory, and you have to give your zip file the correct naming. This should be Resourcename_versionnumber.zip (see screenshot below), and then placed in the “C:\Program Files\WindowsPowerShell\DscService\Modules directory”.PSDSC_Pull_Server

Please be aware that even though its ‘just a zip file’ not all programs zip the same way, if you for example use 7zip or winrar you could bump into eventid 4104: Failed to extract the module from zipfile.                                            PSDSC_notpropperlyzipped

If you however use the windows native compressing engine, everything will work out fine.PSDSC_zippedok