We will need to run the following on Powershell with Administrator rights. # Setup variables $companyName = "contoso" $certFilePath = "$PSScriptRoot\$companyName-wildcard.pfx" $dnsName = "*.$companyName.com" $date = (Get-Date).ToString('MMM-yyyy') $certFriendlyname = "$companyName-wildcard-$date" $certExpiry = (Get-Date).AddYears(10) # Removal existing certificates gci Cert:\LocalMachine\Root | Where FriendlyName -Like "*$companyName*" | Remove-Item gci Cert:\LocalMachine\My | Where FriendlyName -Like "*$companyName*" | Remove-Item # Create self signed certificate and store thumbprint variable $thumb = (New-SelfSignedCertificate -DnsName $dnsName -CertStoreLocation ...
Find where the logs are located for each website Import-Module WebAdministration foreach($WebSite in $(get-website)) { $logFile="$($Website.logFile.directory)\w3scv$($website.id)".replace("%SystemDrive%",$env:SystemDrive) Write-host "$($WebSite.name) [$logfile]" } # Results mysite1.dev[C:\inetpub\logs\LogFiles\w3scv2] mysite2.dev[C:\inetpub\logs\LogFiles\w3scv3] mysite3.dev[C:\inetpub\logs\LogFiles\w3scv4] mysite4.dev[C:\inetpub\logs\LogFiles\w3scv5] mysite5.dev[C:\inetpub\logs\LogFiles\w3scv1] mysite6.dev[C:\inetpub\logs\LogFiles\w3scv6] # Let's ...
Recently wanted to enable remote management of a server via powershell so that I could try out Project Honolulu for managing Windows Servers Make sure WinRM service is running and start up to automatic Get-Service winrm Enable Powershell Remoting Enable-PSRemoting -Force Ensure network profiles are ok # Show network profile > Get-NetConnectionProfile Name : Network InterfaceAlias : Ethernet InterfaceIndex : 2 NetworkCategory : Public IPv4Connectivity : Internet IPv6Connectivity : NoTraffic # Set network profile from Public to Private > Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private # Verify the update completed > ...
Setting up Visual Studio Build Tools 2017 Recently wanted to setup a Windows Server Core VM/image for portability. It's mainly used to build ASP.NET MVC web apps on the full .NET Framework which would then need to be deploy to Azure. Just documenting the steps I took along the way. # Download and install VS Build Tools Invoke-WebRequest https://aka.ms/vs/15/release/vs_buildtools.exe -OutFile vs_buildtools.exe ; Start-Process -FilePath 'vs_BuildTools.exe' -ArgumentList ` '--quiet', '--norestart', ...
Recently, I've been testing ASP.NET MVC's Output Cache feature and wanted to test using different parameters such as VaryByCustom which would read a user's cookies and construct a cache key according to some value. I ended up having to log in and out of Google Chrome, Firefox, Edge etc just to test this so I created a script to do so instead. $loginUrl = "https://example.com/log-in" $normalUrl = "https://example.com/logged-in-area" $postParams = @{email='foo@ ...
Commands and usage Autocompletion (tab and ctrl + space ing) Autocompletion is your friend when it comes to using Powershell. For example, if I want to see a list of running services on my machine I can execute Get-Service but what if I only wanted to see a list subset of that filtered by some property? How would I know what properties I can filter by? ctrl + space to the rescue! Enter Get-Service | Where-Object -Property followed by a ctrl + space this ...
Recently I've been trying to scale my Azure SQL database up from a low pricing tier to a higher pricing tier. It seems like the process can take between minutes to hours. I wanted a way of measure how long this would take and while using the Measure-Command commandlet was useful in showing the duration, it didn't show the time it was executed from start to finish. While the duration was helpful, it didn't really reflect the true amount of ...
Recently I've setup active geo-replication for my database hosted on Azure which basically allows you to asynchronously replicate transactions held on a primary database to a secondary database (usually located in a different geographical region) which is set to read only. The problem was, in a failover/disaster recovery situation, for the secondary to be usable, I would have to manually add all the existing firewall rules on the primary to the secondary which may be updated from time to ...
Two ways to run Powershell Scripts on Azure are on the Azure Automation and Azure Functions platforms. While Microsoft has provided a nice article about the comparisons between Azure Flow, Logic Apps, Functions, and WebJobs, there hasn't been a comparison between Azure Automation and Azure Functions. @johnliu took some notes at MSAUIgnite and posted it on Github which I thought I would share here as well. ...
I've currently got about 40-50 apps running on Azure's App service offering being deploying using Azure ARM deployment templates. Each app contains AppSettings. There were times when I've noticed that some apps don't get all the AppSettings defined in the ARM template so I wrote a script to print and export the list of appsettings for each of my 40-50 apps for sanity checking. $allWebApps = Get-AzureRmWebApp #$allWebApps = $allWebApps | Where-Object {$_.ResourceGroup -eq 'nameOfresourceGroup'} $resourceGroups = $allWebApps | Select-Object 'ResourceGroup' -Unique $outItems = New-Object System. ...
I wanted to run a custom exe (in my case it was called Warmsole.exe) file as part of my Release Definition using the "Command Line" VSTS task that came out of the box. This task required me to locate the path to the exe. Turns out it isn't a straight forward task as the artefacts are downloaded to a directory prefixed by a Artifact source alias (in my case was called my-build-definition). I have an artefact called ...
Things I learnt Postman Monitors services Postman Environments Cannot have multiple cname for a given name References https://blogs.technet.microsoft.com/josebda/2015/04/18/windows-powershell-equivalents-for-common-networking-commands-ipconfig-ping-nslookup/ ...