PSGUI – Debugggingg – HowTo

Hi together,

today i want to show you, how you can debug XAML GUIs created with PSGUI.
And to be honest – this is absolutely easy! You don´t think so? Take a look below.

Continue reading

Advertisements

SCCM 1606 – UserVoice

Hi everyone,

SCCM 1606 with its new features has been announced:

Link Here

In a short:

  • ConfigMgr as a managed installer for easier application whitelisting on Windows 10
  • Cloud Proxy Service
  • Grace period for application and software update deployments
  • Multiple device management points for Windows 10 Anniversary Edition devices
  • Intune: Device categories

Do you like it?
Don´t forget to share thoughts via the UserVoice:
https://configurationmanager.uservoice.com/

Best regards,

David

PS – External Utilities – german console with umlauts

Hi all,

i am using a german console with german words. Many of you know that we use “very special characters” also called umlauts: “ÄÜÖ”.

The interesting part is – if you try to use external tools as the following and they normally would return any values with umlauts this will not work out from Powershell; Let´s say for this example you created a shared directory named ‘ÄÜÖ’:

net.exe VIEW \\localhost\ /all

Here you would get something like this by using it in Powershell:


Freigabename  Typ     Verwendet als  Kommentar         

-------------------------------------------------------------------------------
ADMIN$        Platte                 Remoteverwaltung
Bilder        Platte
C$            Platte                 Standardfreigabe
IPC$          IPC                    Remote-IPC
print$        Platte                 Druckertreiber
Users         Platte
Ž™š           Platte
Der Befehl wurde erfolgreich ausgefhrt.

This error is caused by not matching encodings. Therefore these have to be set previously for the console itself. But here comes again another tricky part. Till now – you would get an error by setting the consoles encoding without having used the cmd.exe out of powershell before, because the handle to the console has to be created previously. Therefore the way to get this to work would be like this:

cmd /c ''
if ([Console]::OutputEncoding.CodePage -ne 852 )
{
    [Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding(852)
}
net.exe VIEW \\localhost\ /all

#getting only the specific line
net.exe VIEW \\localhost\ /all | Select-String 'Ö'
net.exe VIEW \\localhost\ /all | Where-Object { $_ -like '*Ö*' }

With following result:

Freigabename  Typ     Verwendet als  Kommentar         

-------------------------------------------------------------------------------
ADMIN$        Platte                 Remoteverwaltung  
Bilder        Platte                                   
C$            Platte                 Standardfreigabe  
IPC$          IPC                    Remote-IPC        
print$        Platte                 Druckertreiber    
Users         Platte                                   
ÄÖÜ           Platte                                   
Der Befehl wurde erfolgreich ausgeführt.

I am pretty sure that german readers may need this information some time.

Best regards,
David

PS – CleanUp HDD

Hello together,

today i want to show you a simple but effective method to cleanup your HDD. This will also remove the installation data of previous installations and may prompt therefore for authorization. Run it with admin rights.

CleanUp.png

More information here

Set-Location 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\'

foreach ($item in $(Get-ChildItem).PSPath)
{
    if (-not (Get-ItemProperty -Path $item -Name 'StateFlags1234'))
    {
        New-ItemProperty -Path $item -Name 'StateFlags1234' -Value 2
    }
}

cleanmgr.exe /sagerun:1234 

Greetings,

David

Client – Repairing Win 10 Apps with PS

Hello together,

today i want to share with you just two Powershell commands to reinstall Cortana or the Windows App Store if you are facing some problems with these:

Cortana:

Get-AppXPackage -Name Microsoft.Windows.Cortana | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}

Windows App Store:

Get-AppXPackage *WindowsStore* -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}

Greetings,

David

PS OpenFileDialog

Hello together,

here a simple smart function to show an open file dialog:

function Show-OpenFileDialog
{
    <#
            .SYNOPSIS
            Shows up an open file dialog.
            .EXAMPLE
            Show-OpenFileDialog
    #>
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory=$false, Position=0)]
        [System.String]
        $Title = 'Windows PowerShell',
        
        [Parameter(Mandatory=$false, Position=1)]
        [Object]
        $InitialDirectory = "$Home\Documents",
        
        [Parameter(Mandatory=$false, Position=2)]
        [System.String]
        $Filter = 'PowerShell-files|*.ps1|Everything|*.*'
    )
    
    Add-Type -AssemblyName PresentationFramework
    
    $dialog = New-Object -TypeName Microsoft.Win32.OpenFileDialog
    $dialog.Title = $Title
    $dialog.InitialDirectory = $InitialDirectory
    $dialog.Filter = $Filter
    if ($dialog.ShowDialog())
    {
        $dialog.FileName
    }
    else
    {
        Throw 'Nothing selected.'    
    }
}

Show-OpenFileDialog

Have fun with it!

Greetings,

David

PS – DynamicParam

Hello together,

in this post i want to show you a very rare function attribute. It is called dynamicparam and as the name says it adds some features to create parameters dynamically when the user writes the execution function:



function Test-DynamicParam 
{
    [CmdletBinding()]
    param( 
        [Parameter(ValueFromPipeline=$true)]
        $Count 
    )
    
    
    dynamicparam
    {
        $paramDictionary = New-Object -TypeName System.Management.Automation.RuntimeDefinedParameterDictionary
        foreach ($Property in (1..$Count))
        {
            $attributes = New-Object System.Management.Automation.ParameterAttribute
            $attributes.ParameterSetName = '__AllParameterSets'
            $attributes.Mandatory = $false
            $attributeCollection = New-Object -TypeName System.Collections.ObjectModel.Collection[System.Attribute]
            $attributeCollection.Add($attributes)
            $Name = &quot;DynamicParam_$Property&quot;
            $dynParam = New-Object -TypeName System.Management.Automation.RuntimeDefinedParameter($Name,
            [int32], $attributeCollection)
            $paramDictionary.Add($Name, $dynParam)
        }
            
        $paramDictionary
    }
    
    
    begin
    {}
    
    process
    {    &quot;Entered: $Count&quot;
    }
    
    end
    {}
}

Test-DynamicParam -Count 5 

In this example the user enters the function name and the parameter $count. As you can see in the dynamicparam block now additional parameters are created. If you enter for example the number 5 – 5 additional parameters show up and can be given to the function.

DynamicParam.png

So you can add or remove parameters depending on the parameters which the user entered which can be very powerful if you write very complex functions.

Give it a look

Greetings,

David

PowerTheShell – ISESteroids! PSConfEU!

Hello together,

i have arrived today from a very good Powershell Training with Dr. Tobias Weltner, MVP. I have learned plenty new stuff and will blog lots of the new knowledge in the upcoming weeks.

1

The first thing i have to tell you – get a damn ISESteroids license! I did try it previously and liked it very much but had some scepsis to invest the money. After investigating 3 days the functions which all come along with the Steroids i have to say – its just amazing and a must have. Here are just some of them:

  • WPF Dialog creator
  • Variable Monitor
  • Snippet Manager
  • Creating executable files (.exe)
  • Creating functions and modules withing a click
  • Build-in signing and – much – more

Try it by yourself and get a trial. Just take a look at http://www.powertheshell.com/ 

If you want to create good Powershell scripts this tool is just a must have at the moment.


 

Also a very important information for all powershell fanatics – take a look at the upcoming event Powershell Conference EU 2016 http://www.psconf.eu/

There will be some interesting speakers! Trust me!

Greetings,

David