Posts

Showing posts with the label PowerShell

Default Browser - set url association with PowerShell

 Something that is helpful to know for complicated environments. Background: We have a legacy software that is in the process of being rewritten as a Blazor application, as we begin integrating these things together one need is to make sure that invoked urls do not open in Internet Explorer.  Policy and OU based controls are not available within the timeline we're looking at. However we have an advantage in the fact that we're already using a .ps1 script that prepares some environment needs before  the software executes. Other alternatives: A popular recommendation for handling this is to work within the DefaultAssociationsConfiguration structure. This is a good option, and is well covered in articles like this:  set-default-browser-to-microsoft-edge-using-powershell/ Why this solution: This solution fits a need where anything that may cause IE to be reset as default is handled promptly without requiring a logoff or restart to take effect.  Components: Registry ...

Powershell OpenFileDialog

This is my preferred version of a function for calling a Windows GUI OpenFileDialog. Adding a few GUI elements can be the difference between a script for your own use, and a sharable tool that people with less experience (or fear of CLI) can use. This function invokes the standard .NET System.windows.forms tools within a PowerShell context. Function Get-FilesFromDialog () {     Param (     [ Parameter ( Mandatory =$ False )][ String []]$ myInitialDirectory = $ env:USERPROFILE ,     [ Parameter ( Mandatory =$ False )][ String []]$ myTitle = "Open File" ,     [ Parameter ( Mandatory =$ False , )][ String []]$ myFilterString = ""  )  [ System.Reflection.Assembly ]::LoadWithPartialName( “System.windows.forms” ) | Out-Null  $ OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog  $ OpenFileDialog .initialDirectory = $ myInitialDirectory  $ OpenFileDialog .filter = " $ myFilterString " + “All files (*.*)...

Orchestrator Runbooks and PowerShell literals

This specific strategy hasn't had much field testing yet, so this is a proof-of-concept overview. Our admin who runs System Center Orchestrator realized a logical flaw in a lot of Orchestrator PowerShell examples and templates. Most examples show something like this: # Set script parameters from runbook data bus and Orchestrator global variables # Define any inputs here and then add to the $argsArray and script block parameters below  $DataBusInput1   =   "{Parameter 1 from Initialize Data}" $DataBusInput2   =   "{Global Variable 1}" Taken from  PowerShell & System Center Orchestrator - Best Practice Template - TechNet Articles - United States (English) - TechNet Wiki (microsoft.com) What orchestrator runs that script; it performs inline concatenation of its variables into the PowerShell scri...