To determine a range of websites dns, registrar and IPOwner and what technology is used the following script can be used.
Note that whois64.exe referred to in script needs to be downloaded seperatly from Sysinternals/Microsoft
References:
https://docs.microsoft.com/en-us/sysinternals/downloads/whois
Reflections over the current computer issues from an struggling network technician
Tuesday, June 18, 2019
Thursday, February 07, 2019
enumerate columns from subsites
This case is something which I've came back to a few times.
Customer wants to output columns from certain content types from a number of sites.
Its always a hassle to get the correct names of columns so I've built a method to output the values more dynamically.
1. First getFields.ps1 reads columns containg values from a list item, outputs to gridview, chosen values gets saved to customfields.csv
2. Second getSitecontenttypefields.ps1 enumerates all sites on chosen destination and loops all items of specified content types and outputs chosen fields from customfields.ps1 to an object which is saved to a csv-file.
Customer wants to output columns from certain content types from a number of sites.
Its always a hassle to get the correct names of columns so I've built a method to output the values more dynamically.
1. First getFields.ps1 reads columns containg values from a list item, outputs to gridview, chosen values gets saved to customfields.csv
2. Second getSitecontenttypefields.ps1 enumerates all sites on chosen destination and loops all items of specified content types and outputs chosen fields from customfields.ps1 to an object which is saved to a csv-file.
Thursday, December 20, 2018
CertAuto
For a developer environment I had a few certificates that needed automatic renewal at certain intervals. The script below uses the PSPKI module to check if certificates are expiring on IIS-Site in X days and if so, renews the agains a local certification authority.
The PSPKI -module is really god for sending and approving certification requests via Powershell when Microsofts own tools leaves room for improvement.
This is really only for a testenviroment and offline-enviroments.
Folder structure needs to created to look below

Certini contains the template for the certificate like below for example
[Version]
Signature = "$Windows NT$"
[NewRequest]
Subject = "C=US,S=CA,L=OHIO,O=Fabrikam,OU=IT,CN=ajax.aspnetcdn.com"
Exportable = TRUE
KeyLength = 4096
KeySpec = 1
KeyUsage = 0xa0
MachineKeySet = True
ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
ProviderType = 12
Silent = True
SMIME = False
RequestType = PKCS10
FriendlyName = "ajax.aspnetcdn.com"
References:
https://www.sysadmins.lv/projects/pspki/default.aspx - PSPKI Module
The PSPKI -module is really god for sending and approving certification requests via Powershell when Microsofts own tools leaves room for improvement.
This is really only for a testenviroment and offline-enviroments.
Folder structure needs to created to look below
Certini contains the template for the certificate like below for example
[Version]
Signature = "$Windows NT$"
[NewRequest]
Subject = "C=US,S=CA,L=OHIO,O=Fabrikam,OU=IT,CN=ajax.aspnetcdn.com"
Exportable = TRUE
KeyLength = 4096
KeySpec = 1
KeyUsage = 0xa0
MachineKeySet = True
ProviderName = "Microsoft RSA SChannel Cryptographic Provider"
ProviderType = 12
Silent = True
SMIME = False
RequestType = PKCS10
FriendlyName = "ajax.aspnetcdn.com"
References:
https://www.sysadmins.lv/projects/pspki/default.aspx - PSPKI Module
Monday, June 04, 2018
Export IIS bindings
I find the cmdlet for exporting cmdlets a bit lacking so I built my own export function for fun and profit.
The function in the toolsfile collects all info and return a populated object that can be used to export list to file or do something else with.
The function in the toolsfile collects all info and return a populated object that can be used to export list to file or do something else with.
Thursday, May 17, 2018
Digging through a lot of files
I have a scenario where I need to scan a lot of xmlfiles from elmah-logs in the size of 300 000 files.
Powershell was a fun project for this but couldn't really do the job due to performance issues.
When reading 300 000 files using powershell like example below, the script ran for 368 minutes.
I tried running parallell jobs and using dotnet to read files instead but nothing could complete with using MS Logparser.
So enter Log Parser Studio.
This neat tool managed to comb through 300 000 files in 47 minutes instead!
It is a bit tricky to formulate the queries however. Heres an example of getting elmah logs where a variable named HTTP_REFERER contains a key value
select * FROM '[LOGFILEPATH]' where string like '%http://www.mycompany.com/subsite%' and name like 'HTTP_REFERER'
So in conclusion for same set of 300 000 files
Powershell took 368 minutes
Log Parser Studio took 47 minutes
Powershell was a fun project for this but couldn't really do the job due to performance issues.
When reading 300 000 files using powershell like example below, the script ran for 368 minutes.
I tried running parallell jobs and using dotnet to read files instead but nothing could complete with using MS Logparser.
So enter Log Parser Studio.
This neat tool managed to comb through 300 000 files in 47 minutes instead!
It is a bit tricky to formulate the queries however. Heres an example of getting elmah logs where a variable named HTTP_REFERER contains a key value
select * FROM '[LOGFILEPATH]' where string like '%http://www.mycompany.com/subsite%' and name like 'HTTP_REFERER'
So in conclusion for same set of 300 000 files
Powershell took 368 minutes
Log Parser Studio took 47 minutes
References:
Thursday, May 03, 2018
Using hashtables to combine values
For a job I needed a good way of combining a primary value with optional subvalues in a xml-file.
Below is an example of how to extract attributes from a xmlelement into a hashtable and then join two hashtables into one. I couldn't find a method for extracting elements on the web, folks usually goes with subnodes instead of attributes. I'm partial to attributes and had to get creative, but the solution was quite simple. The Attributes from the element only show the actual elements from the xmlfile. Its not obvious when browsing the object that -name property can be lifted, but here it's used for creating a new hashtable-row
Samplescript for proof of concept
This eventually led to createwebsFromStructure.ps1 that uses powershell splatting to build commands with the resulting hashtable.
References:
https://powershell.org/2013/01/23/join-powershell-hash-tables/ - source for join-hashtable function
https://technet.microsoft.com/en-us/library/gg675931.aspx - source for details on splatting
Below is an example of how to extract attributes from a xmlelement into a hashtable and then join two hashtables into one. I couldn't find a method for extracting elements on the web, folks usually goes with subnodes instead of attributes. I'm partial to attributes and had to get creative, but the solution was quite simple. The Attributes from the element only show the actual elements from the xmlfile. Its not obvious when browsing the object that -name property can be lifted, but here it's used for creating a new hashtable-row
Samplescript for proof of concept
This eventually led to createwebsFromStructure.ps1 that uses powershell splatting to build commands with the resulting hashtable.
References:
https://powershell.org/2013/01/23/join-powershell-hash-tables/ - source for join-hashtable function
https://technet.microsoft.com/en-us/library/gg675931.aspx - source for details on splatting
Friday, January 12, 2018
Powershell and jobs
Powershell jobs are a bit of blunt instrument.
Here's two options for sending inputs for them
Scenario 1: Sending a string with all of our values and splitting them to an array when inside the scriptblock.
Scenario2: Sending an object as input. Handy for configs and saves the need to define variablenames.
Here's two options for sending inputs for them
Scenario 1: Sending a string with all of our values and splitting them to an array when inside the scriptblock.
Scenario2: Sending an object as input. Handy for configs and saves the need to define variablenames.
Subscribe to:
Posts (Atom)
Powershell and Uptimerobot
Uptimerobot can be quite tedious when you need to update many monitors at once. For example say you bought the license for Uptimerobot and n...
-
I had a case where a customer wanted to run RDS on singleserver. The idea was to run DC and TS on the same server to save hostingmoney. A ba...
-
When setting up a special user that is used to copy a lot of items we today learned about the default throttling restrictions in Exchange 20...
-
Uptimerobot can be quite tedious when you need to update many monitors at once. For example say you bought the license for Uptimerobot and n...