Jekyll2022-03-08T09:20:08+00:00https://www.techfreak.ch/feed.xmltechfreak.ch BlogSome stuff for me to rememberUninstall old PowerShell Module Versions2018-11-12T00:00:00+00:002018-11-12T00:00:00+00:00https://www.techfreak.ch/blog/2018/11/12/uninstall-old-powershell-module-versions<p>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:</p>
<script src="https://gist.github.com/MichelZ/197da5830b6e073183619e302e95145f.js"></script>
<noscript>
<pre>
```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...
```
</pre>
</noscript>
<p>To get rid of the old versions, you can use this easy script:</p>
<script src="https://gist.github.com/MichelZ/e4efbafc6dcc2f8a56583d3053588dc4.js"></script>
<noscript>
<pre>
```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
}
```
</pre>
</noscript>
<p>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.</p>Michel Zehndermichel.zehnder@techfreak.chIf 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:Test2018-11-04T00:00:00+00:002018-11-04T00:00:00+00:00https://www.techfreak.ch/blog/2018/11/04/first-post<p>Test using Jekyll</p>Michel Zehndermichel.zehnder@techfreak.chTest using JekyllFirmware security rules2016-10-22T00:00:00+00:002016-10-22T00:00:00+00:00https://www.techfreak.ch/blog/2016/10/22/firmware-security-rules<p>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 > 1 Tbps traffic to their Infrastructure.</p>
<p>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.</p>Michel Zehndermichel.zehnder@techfreak.chAfter 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 > 1 Tbps traffic to their Infrastructure.Certificate Template not available2016-10-18T00:00:00+00:002016-10-18T00:00:00+00:00https://www.techfreak.ch/blog/2016/10/18/certificate-template-not-available<p>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..</p>Michel Zehndermichel.zehnder@techfreak.chOne 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..Change DNS Server for DNS Clients in Domain2016-10-17T00:00:00+00:002016-10-17T00:00:00+00:00https://www.techfreak.ch/blog/2016/10/17/change-dns-server-for-dns-clients-in-domain<p>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.</p>
<script src="https://gist.github.com/MichelZ/c16dbceb4bdb865c64f9a5bdb33c6254.js"></script>
<noscript>
<pre>
```powershell
# Get Computers from Active Directory
$computers = Get-ADComputer -SearchBase "OU=Servers,OU=Computers,OU=Accounts,DC=domain,DC=local" -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("192.168.0.231","192.168.0.232","192.168.0.233","2001:db8:dead:beef::231","2001:db8:dead:beef::232","2001:db8:dead:beef::233")
}
} -AsJob
}
```
</pre>
</noscript>
<p>You can watch the progress using</p>
<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">Get-Job</span><span class="w">
</span></code></pre></div></div>
<p>Simple, and pretty fast.</p>Michel Zehndermichel.zehnder@techfreak.chRecently 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.