Pester tests for PowerShell modules

if you write regularly PowerShell modules, you have to test the functions in it.

i wrote some Pester tests, which are doing this tests for all functions in a PowerShell module:

  • the function has SYNOPSIS, DESCRIPTION and EXAMPLES
  • the function has cmdletbinding
  • the function has an OutputType defined
  • the function name starts with an approved verb
  • the function name has an common prefix
  • all parameters have a help text
  • all parameters have a type declaration
  • all variables inside the function has the same upper/lower case
  • read more

    pass parameter values to Invoke-CMScript

    The Invoke-CMScript cmdlet invokes a PowerShell script in Microsoft System Center Configuration Manager. System Center Configuration Manager has an integrated ability to run Powershell scripts. The scripts simplify building custom tools to administer software and let you accomplish mundane tasks quickly, allowing you to get large jobs done more easily and more consistently. For more information, see Create and run PowerShell scripts from the Configuration Manager console.

    unfortunately the Invoke-CMScript doesn’t allow to pass values to defined  script params. if you want to do this, you have to invoke the script through the Configuration Manager console. read more

    PowerShell and PSHTML in Azure Function App

    PowerShell is now available in Azure Function App (still in preview).

    you can create a Powershell Function App like this:

    using PowerShell modules

    currently, you can’t install a powershell module inside Azure Function App, but you can upload your module to the script directory and access it from there. to do this, use Kudu:

    browse to site / wwwroot:

    then you can drag and drop your module ZIP-file to the right part of the explorer

    the file will be uploaded and unpacked automatically

    now you can reference this module directly from your function script read more

    getting info about users password expiration

    i work in a multi domain environment. each domain has different password expiration rules. unfortunattely there is no notification system for the password expiration, so i have to check manually how long my passwords are valid.

    for this, i wrote this PowerShell function, which does work without the use of any additional module:

    the result of this script looks like this:

     

    reclaime diskspace on zero detection storage when deletening vmware vm

    some time ago, i had the problem that my 3Par storage was getting full. in this time i removed a lot of test vm’s from this storage, but nothing happens. the storage was still full. the reason was the mechanisme how vmware deletes files from a DataStore and the activated zero-detection feature on the storage. if you delete a virtual disk file on the vmware datastore, it will only marked as deleted, but the datas are still there in the same format. to get the storage’s zero detection work, we have to zero out the deleted part of the datastore manually.

    you can do this with this script:

     

    how to get the correct Virtual Disk for a VMware vm

    Some times I have the problem, I need to resize or delete a VMware virtual disk, but I only know the guest’s drive letter. In vm’s where there are only one virtual disk, or where each virtual disk has a different size, this isn’t a problem. but if you have a vm with multiple virtual disk with exactly the same size, you can’t compare it between the guest Disk Manager and the virtual disk sizes. if your vm has more than one SCSI controller, the problem will increase.

    Windows Disk Manager VMware VM settings

    I searched long time to solve this problem, but I couldn’t find an easy solution for this. so I wrote this PowerShell script:

    when you run the script, it will ask you for credentials and then shows you the informations about booth of your virtual disk and Windows drive :

    website rebranding

    Hello

    my website was over years reachable under josh-burkard.ch, which was a long url. I was on search for a new and shorter domain name for this website. now I have found one, which is shorter and which describes what i’m doing and writing about: Information Technology (IT). So, my new web address is burkard.IT

    of course, the old address will be available, but I would like the new shorter one.

     

    Proxy autoconfiguration with WPAD.dat and multiple network adapters

    If you use a proxy server in your company, you would like to automatically configure your clients using a WPAD.dat-file. If you use the myIpAddress()-function, this function will returns the ip address from one active network adapter, maybe from the wrong one. This function couldn’t determine, which network adapter would made the connection to your proxy server. In this case you couldn’t connect to the internet, cause the WPAD.dat file returns the wrong result.

    There is no automatic metric inside the WPAD.dat to detect, which adapter is the active adapter, nearest to your proxy server. You need to set the ip metric manualy on each network adapter:

    Go to your network settings:

    right click your prefered network adapter and select Properties:

    Select IPv4 and click to Properties:

    Click to Advanced

    Disable the checkbox near to Automatic metric and set in the field Interface metric a value of 1.

    Repeat this steps through all your nic’s, by incrementing the last value for prioritize your connections.

     

    disable Outlook AutoDiscovery feature for a mail domain

    Maybe you want to disable the autodiscovery feature in Outlook 2007 / 2010 for your full mail domain – maybe you don’t like the feature, or your mail server doesn’t support it.

    For this, there is an easy solution:

    Define in your DNS-server an A-entry for autodiscover.domain.com pointing to 127.0.0.1.