# Austria PowerShell User Group: Microsoft.PowerShell.Crescendo #-------------------------------------------------------------- #-------------------------------------------------------------- #Region: Crescendo Links. # Clear the PowerShell hosting program. Clear-Host # Assign paths to array variable. $Paths = # Native Commands in PowerShell – A New Approach. 'https://devblogs.microsoft.com/powershell/native-commands-in-powershell-a-new-approach/', # Native Commands in PowerShell – A New Approach – Part 2. 'https://devblogs.microsoft.com/powershell/native-commands-in-powershell-a-new-approach-part-2/', # TheShow:20:E4-Native Command Experience with Jim Truher. 'https://www.youtube.com/watch?v=nljm_lIKink', # Announcing PowerShell Crescendo Preview.1. 'https://devblogs.microsoft.com/powershell/announcing-powershell-crescendo-preview-1/', # Github Project for PowerShell/Crescendo. 'https://github.com/PowerShell/Crescendo', # PowerShell Gallery: Microsoft.PowerShell.Crescendo. 'https://www.powershellgallery.com/packages/Microsoft.PowerShell.Crescendo' # Open above links in a loop. 0..5 | ForEach-Object {Start-Process -FilePath $Paths[$_]; Start-Sleep -Milliseconds 500} #endregion. #-------------------------------------------------------------- #Region: Module install, details, commands, and information. # Clear the PowerShell hosting program. Clear-Host # Install the Microsoft.PowerShell Crescendo module. # Install-Module -Name Microsoft.PowerShell.Crescendo # Return Crescendo module base information. Get-Module -Name Microsoft.PowerShell.Crescendo -ListAvailable # Clear the PowerShell hosting program. Clear-Host # Import Crescent 0.4.1 (preview-1) $Module = 'Microsoft.PowerShell.Crescendo' Remove-Module -Name $Module -ErrorAction SilentlyContinue Import-Module -Name $Module -RequiredVersion 0.4.1 Get-Module -Name $Module # Return Crescendo module commands. Get-Command -Module Microsoft.PowerShell.Crescendo # Return Crescendo module about information. # Get-Help -Name about_Crescendo #endregion. #-------------------------------------------------------------- #Region: Part I # Clear the PowerShell hosting program. Clear-Host # First Crescendo post. Start-Process -FilePath 'https://tommymaynard.com/simple-simple-microsoft-crescendo-example/' # Remove mstsc Crescendo file (if it exists). $Path = "$env:USERPROFILE\Documents\PowerShell\Modules\Microsoft.PowerShell.Crescendo\0.4.1\Samples" Remove-Item -Path "$Path\mstsc.Crescendo.json" -ErrorAction SilentlyContinue # Open Crescendo examples folder. Invoke-Item -Path $Path # Copy/Rename dd.Crescendo.json to mstsc.Crescendo.json. Copy-Item -Path "$Path\dd.Crescendo.json" -Destination "$Path\mstsc.Crescendo.json" # Open mstsc.Crescendo.json file. Invoke-Item -Path "$Path\mstsc.Crescendo.json" # Manual edits to complete. ## 1. Removed the "Output" parameter ## 2. Change Verb from "Invoke" to "Connect". ## 3. Change Noun from "DD" to "RemoteComputer". ## 4. Change OriginalName to "/Windows/System32/mstsc.exe" ## 5. Remove SupportsShouldProcess line. ## 5. Edit Parameter: "Name":"ComputerName" ## "OriginalName: "/v" ## "ParameterType": "string" # Remove RemoteComputer.psm1 module (if it exists). Remove-Item -Path 'RemoteComputer.psm1' -ErrorAction SilentlyContinue # Create RemoteComputer.psm1 module from Crescend JSON file. Export-CrescendoModule -ConfigurationFile "$env:USERPROFILE\Documents\PowerShell\Modules\Microsoft.PowerShell.Crescendo\0.4.1\Samples\mstsc.Crescendo.json" -ModuleName 'RemoteComputer.psm1' # Get RemoteComputer.psm1 module file. Get-Item -Path 'RemoteComputer.psm1' # Clear the PowerShell hosting program. Clear-Host # Import RemoteComputer.psm1 module and verify. Import-Module -Name '.\RemoteComputer.psm1' Get-Module -Name RemoteComputer # Invoke Connect-RemoteComputer. Connect-RemoteComputer Connect-RemoteComputer -ComputerName DC01 #endregion. #-------------------------------------------------------------- #Region: Part II # Clear the PowerShell hosting program. Clear-Host # Second Crescendo post. Start-Process -FilePath 'https://tommymaynard.com/simple-simple-microsoft-crescendo-example-part-ii/' # Remove RemoteComputer.psm1 module (if it exists). Remove-Item -Path 'RemoteComputer.psm1' -ErrorAction SilentlyContinue; Clear-Host # Invoke New-CrescedoCommand function. $Command = New-CrescendoCommand -Verb Connect -Noun RemoteComputer $Command # Add OriginalName property $Command.OriginalName = "C:/Windows/System32/mstsc.exe" $Command # Display GitHub Crescendo Issue for OriginalName parameter. Start-Process -FilePath 'https://github.com/PowerShell/Crescendo/issues/82' # Clear the PowerShell hosting program. Clear-Host # Convert $Command to JSON. $Command = $Command | ConvertTo-Json $Command # Clear the PowerShell hosting program. Clear-Host # Invoke New-ParameterInfo function. $Parameter = New-ParameterInfo -Name ComputerName -OriginalName /v $Parameter # Convert $Parameter to JSON. $Parameter = $Parameter | ConvertTo-Json $Parameter # Clear the PowerShell hosting program. Clear-Host # Invoke New-UsageInro function. $Usage = New-UsageInfo -usage 'Runs Remote Desktop Connection' $Usage # Convert $Usage to JSON. $Usage = $Usage | ConvertTo-Json $Usage # Clear the PowerShell hosting program. Clear-Host # Invoke New-ExampleInfo function. $Example = New-ExampleInfo -command Connect-RemoteComputer -originalCommand 'C:\Windows\System32\mstsc.exe' -description 'Wraps Remote Desktop Connection' $Example # Convert $Example to JSON. $Example = $Example | ConvertTo-Json $Example # Clear the PowerShell hosting program. Clear-Host # Open Collective JSON file. Invoke-Item -Path '.\Dropbox\PowerShell\AustriaUG\PartII_Json.json' # Save PartII_Json.json as mstsc.Crescendo.json. Copy-Item -Path '.\Dropbox\PowerShell\AustriaUG\PartII_Json.json' -Destination "$env:USERPROFILE\Documents\PowerShell\Modules\Microsoft.PowerShell.Crescendo\0.4.1\Samples\mstsc.Crescendo.json" # Create RemoteComputer.psm1 module from Crescend JSON file. Export-CrescendoModule -ConfigurationFile "$env:USERPROFILE\Documents\PowerShell\Modules\Microsoft.PowerShell.Crescendo\0.4.1\Samples\mstsc.Crescendo.json" -ModuleName 'RemoteComputer.psm1' # Clear the PowerShell hosting program. Clear-Host # Import RemoteComputer.psm1 module and verify. Import-Module -Name '.\RemoteComputer.psm1' -Force Get-Module -Name RemoteComputer # Invoke Connect-RemoteComputer. Connect-RemoteComputer Connect-RemoteComputer -ComputerName DC02 mstsc.exe /v DC02 #endregion. #-------------------------------------------------------------- #Region: Crescendo Preview 2 Start-Process -FilePath 'https://devblogs.microsoft.com/powershell/announcing-powershell-crescendo-preview-2/' #endregion #--------------------------------------------------------------