<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="https://www.techfreak.ch/feed.xml" rel="self" type="application/atom+xml" /><link href="https://www.techfreak.ch/" rel="alternate" type="text/html" /><updated>2022-03-08T09:20:08+00:00</updated><id>https://www.techfreak.ch/feed.xml</id><title type="html">techfreak.ch Blog</title><subtitle>Some stuff for me to remember</subtitle><entry><title type="html">Uninstall old PowerShell Module Versions</title><link href="https://www.techfreak.ch/blog/2018/11/12/uninstall-old-powershell-module-versions" rel="alternate" type="text/html" title="Uninstall old PowerShell Module Versions" /><published>2018-11-12T00:00:00+00:00</published><updated>2018-11-12T00:00:00+00:00</updated><id>https://www.techfreak.ch/blog/2018/11/12/uninstall-old-powershell-module-versions</id><content type="html" xml:base="https://www.techfreak.ch/blog/2018/11/12/uninstall-old-powershell-module-versions">&lt;p&gt;If you’re using a Module like AzureRm, and you update it from time to time (Update-Module), you will find that you’ll have a couple of versions installed of all the individual modules. Something like this:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/MichelZ/197da5830b6e073183619e302e95145f.js&quot;&gt;&lt;/script&gt;

&lt;noscript&gt;
&lt;pre&gt;
```powershell
   Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     0.9.1.326  ACMESharp                           {Get-ACMECertificate, Get-ACMEChallengeHandlerProfile, Get-ACMEIdentifie...
Script     5.3.0      Azure                               {Get-AzureAutomationCertificate, Get-AzureAutomationConnection, New-Azur...
Script     5.1.2      Azure                               {Get-AzureAutomationCertificate, Get-AzureAutomationConnection, New-Azur...
Script     0.5.4      Azure.AnalysisServices              {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisServicesInstance...
Script     0.5.3      Azure.AnalysisServices              {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisServicesInstance...
Script     0.5.2      Azure.AnalysisServices              {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisServicesInstance...
Script     0.5.1      Azure.AnalysisServices              {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisServicesInstance...
Manifest   0.5.0      Azure.AnalysisServices              {Add-AzureAnalysisServicesAccount, Restart-AzureAnalysisServicesInstance...
Script     4.6.1      Azure.Storage                       {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageT...
Script     4.4.0      Azure.Storage                       {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageT...
Script     4.3.2      Azure.Storage                       {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageT...
Script     4.3.1      Azure.Storage                       {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageT...
Script     4.2.1      Azure.Storage                       {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageT...
Script     4.2.0      Azure.Storage                       {Get-AzureStorageTable, New-AzureStorageTableSASToken, New-AzureStorageT...
Binary     2.0.2.4    AzureAD                             {Add-AzureADApplicationOwner, Get-AzureADApplication, Get-AzureADApplica...
Binary     2.0.1.16   AzureAD                             {Add-AzureADApplicationOwner, Get-AzureADApplication, Get-AzureADApplica...
Binary     2.0.1.3    AzureAD                             {Add-AzureADApplicationOwner, Get-AzureADApplication, Get-AzureADApplica...
Script     6.12.0     AzureRM
Script     0.6.14     AzureRM.AnalysisServices            {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesSe...
Script     0.6.11     AzureRM.AnalysisServices            {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesSe...
Script     0.6.10     AzureRM.AnalysisServices            {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesSe...
Script     0.6.8      AzureRM.AnalysisServices            {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesSe...
Script     0.6.6      AzureRM.AnalysisServices            {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesSe...
Script     0.6.5      AzureRM.AnalysisServices            {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesSe...
Script     6.1.5      AzureRM.ApiManagement               {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-A...
Script     6.1.2      AzureRM.ApiManagement               {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-A...
Script     6.1.1      AzureRM.ApiManagement               {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-A...
Script     6.1.0      AzureRM.ApiManagement               {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-A...
Script     5.1.2      AzureRM.ApiManagement               {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-A...
Script     5.1.1      AzureRM.ApiManagement               {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-A...
```
&lt;/pre&gt;
&lt;/noscript&gt;

&lt;p&gt;To get rid of the old versions, you can use this easy script:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/MichelZ/e4efbafc6dcc2f8a56583d3053588dc4.js&quot;&gt;&lt;/script&gt;

&lt;noscript&gt;
&lt;pre&gt;
```powershell
$modules = Get-Module -ListAvailable AzureRm* | Select-Object -ExpandProperty Name -Unique
foreach ($module in $modules)
{
    $Latest = Get-InstalledModule $module; Get-InstalledModule $module -AllVersions | ? {$_.Version -ne $Latest.Version} | Uninstall-Module
}
```
&lt;/pre&gt;
&lt;/noscript&gt;

&lt;p&gt;It loops through all of the modules, retains the latest version of each module, and uninstalls all of the others.
It’s not AzureRm’s fault, it’s the fault of PowerShellGet, with the “Update-Module” functionality not actually being an “Update”, but just a Side-by-Side installation of the new version.&lt;/p&gt;</content><author><name>Michel Zehnder</name><email>michel.zehnder@techfreak.ch</email></author><category term="powershell" /><category term="powershell" /><summary type="html">If you’re using a Module like AzureRm, and you update it from time to time (Update-Module), you will find that you’ll have a couple of versions installed of all the individual modules. Something like this:</summary></entry><entry><title type="html">Test</title><link href="https://www.techfreak.ch/blog/2018/11/04/first-post" rel="alternate" type="text/html" title="Test" /><published>2018-11-04T00:00:00+00:00</published><updated>2018-11-04T00:00:00+00:00</updated><id>https://www.techfreak.ch/blog/2018/11/04/first-post</id><content type="html" xml:base="https://www.techfreak.ch/blog/2018/11/04/first-post">&lt;p&gt;Test using Jekyll&lt;/p&gt;</content><author><name>Michel Zehnder</name><email>michel.zehnder@techfreak.ch</email></author><category term="cat1" /><category term="cat2" /><category term="tag1" /><category term="tag2" /><summary type="html">Test using Jekyll</summary></entry><entry><title type="html">Firmware security rules</title><link href="https://www.techfreak.ch/blog/2016/10/22/firmware-security-rules" rel="alternate" type="text/html" title="Firmware security rules" /><published>2016-10-22T00:00:00+00:00</published><updated>2016-10-22T00:00:00+00:00</updated><id>https://www.techfreak.ch/blog/2016/10/22/firmware-security-rules</id><content type="html" xml:base="https://www.techfreak.ch/blog/2016/10/22/firmware-security-rules">&lt;p&gt;After yesterday’s attack on DynDNS, a provider of vital Infrastructure for the Internet, several big sites, including Reddit and GitHub were down. The speculations are, that IoT devices were used, same as in the last attacks to KrebsOnSecurity and OVH, which had massive 620 Gbps and &amp;gt; 1 Tbps traffic to their Infrastructure.&lt;/p&gt;

&lt;p&gt;Is it time to regulate the security of Firmware for IoT devices? To punish companies which fail to fix security holes? To mandate auto-updating of Firmware to automatically secure these devices? I think it is, because the use of IoT devices will explode in the near future, and if we don’t do something to secure them, we’re shoveling our own digital grave with them.&lt;/p&gt;</content><author><name>Michel Zehnder</name><email>michel.zehnder@techfreak.ch</email></author><category term="cat1" /><category term="cat2" /><category term="security" /><category term="iot" /><summary type="html">After yesterday’s attack on DynDNS, a provider of vital Infrastructure for the Internet, several big sites, including Reddit and GitHub were down. The speculations are, that IoT devices were used, same as in the last attacks to KrebsOnSecurity and OVH, which had massive 620 Gbps and &amp;gt; 1 Tbps traffic to their Infrastructure.</summary></entry><entry><title type="html">Certificate Template not available</title><link href="https://www.techfreak.ch/blog/2016/10/18/certificate-template-not-available" rel="alternate" type="text/html" title="Certificate Template not available" /><published>2016-10-18T00:00:00+00:00</published><updated>2016-10-18T00:00:00+00:00</updated><id>https://www.techfreak.ch/blog/2016/10/18/certificate-template-not-available</id><content type="html" xml:base="https://www.techfreak.ch/blog/2016/10/18/certificate-template-not-available">&lt;p&gt;One thing that I tend to forget when I duplicate a Certificate and I want it to be used in the Certificate Web Enrollment page is that - in addition to needing “Enroll” permissions - I need to set the “Subject Name” Tab to “Supply in the request”. Else this won’t show up..&lt;/p&gt;</content><author><name>Michel Zehnder</name><email>michel.zehnder@techfreak.ch</email></author><category term="system-administration" /><category term="pki" /><category term="windows" /><summary type="html">One thing that I tend to forget when I duplicate a Certificate and I want it to be used in the Certificate Web Enrollment page is that - in addition to needing “Enroll” permissions - I need to set the “Subject Name” Tab to “Supply in the request”. Else this won’t show up..</summary></entry><entry><title type="html">Change DNS Server for DNS Clients in Domain</title><link href="https://www.techfreak.ch/blog/2016/10/17/change-dns-server-for-dns-clients-in-domain" rel="alternate" type="text/html" title="Change DNS Server for DNS Clients in Domain" /><published>2016-10-17T00:00:00+00:00</published><updated>2016-10-17T00:00:00+00:00</updated><id>https://www.techfreak.ch/blog/2016/10/17/change-dns-server-for-dns-clients-in-domain</id><content type="html" xml:base="https://www.techfreak.ch/blog/2016/10/17/change-dns-server-for-dns-clients-in-domain">&lt;p&gt;Recently we had the need to change DNS Servers on a couple of machines.
Rather than logging into every machine and doing this manually, of course we did it using PowerShell! It even works with IPv6.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/MichelZ/c16dbceb4bdb865c64f9a5bdb33c6254.js&quot;&gt;&lt;/script&gt;

&lt;noscript&gt;
&lt;pre&gt;
```powershell
# Get Computers from Active Directory
$computers = Get-ADComputer -SearchBase &quot;OU=Servers,OU=Computers,OU=Accounts,DC=domain,DC=local&quot; -SearchScope 1 -Filter *

# Connect to each computer an change DNS Settings
foreach ($computer in $computers)
{
    Invoke-Command -ComputerName $computer.DNSHostName -ScriptBlock {
        # Only change settings for adapter which have an 192.168.0.* IP Address
        $addresses = Get-NetIPAddress | Where-Object { $_.IPAddress -like '192.168.0.*' }

        foreach ($address in $addresses)
        {
            $ifindex = $addresses.ifIndex
            Set-DnsClientServerAddress -InterfaceIndex $ifindex -ServerAddresses(&quot;192.168.0.231&quot;,&quot;192.168.0.232&quot;,&quot;192.168.0.233&quot;,&quot;2001:db8:dead:beef::231&quot;,&quot;2001:db8:dead:beef::232&quot;,&quot;2001:db8:dead:beef::233&quot;)
        }
    } -AsJob
}
```
&lt;/pre&gt;
&lt;/noscript&gt;
&lt;p&gt;You can watch the progress using&lt;/p&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Get-Job&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Simple, and pretty fast.&lt;/p&gt;</content><author><name>Michel Zehnder</name><email>michel.zehnder@techfreak.ch</email></author><category term="system-administration" /><category term="dns" /><category term="windows" /><summary type="html">Recently we had the need to change DNS Servers on a couple of machines. Rather than logging into every machine and doing this manually, of course we did it using PowerShell! It even works with IPv6.</summary></entry></feed>