# define your different environments $action = @{ 'Azure' = "$PSScriptRoot\azure.ps1" 'Teams' = "$PSScriptRoot\teams.ps1" 'Office' = "$PSScriptRoot\office.ps1" }
# run a new PowerShell for each environment, and run the # associated "spin-up" script: $action.Keys | ForEach-Object { $path = $action[$_] Start-Process-FilePath powershell -ArgumentList"-noexit -noprofile -executionpolicy bypass -file ""$path""" }
# set the console title bar $host.UI.RawUI.WindowTitle = 'Administering Office' # read the common credential from file $cred = Import-Clixml-Path"$PSScriptRoot\secret.xml"
[Enum]::GetNames([System.Environment+SpecialFolder]) | ForEach-Object { # ...for each, create a new object with the constant, the associated path # and the code required to get that path [PSCustomObject]@{ Name = $_ Path = [Environment]::GetFolderPath($_) } }
$data = Get-Content-Path$Path-Raw | ConvertFrom-Json | ForEach-Object { $_ } | ForEach-Object { # define a string describing the video. This string will be shown in a grid view window $title = '{0,5} [{2}] "{1}" ({3})'-f ([Object[]]$_) # add the original data to the string so when the user select a video, # the details i.e. download URL is still available $title | Add-Member-MemberType NoteProperty -NameData-Value$_-PassThru }
$data | Sort-Object | Out-GridView-Title'Select Video(s)'-OutputMode Multiple | ForEach-Object { # take the download URL from the attached original data $url = $_.Data[5] $filename = Split-Path-Path$url-Leaf $filepath = Join-Path-Path$env:temp-ChildPath$filename $title = 'Video download {0} ({1})'-f$_.Data[1], $_.Data[0] Start-BitsTransfer-Description$title-Source$url-Destination$filepath # you can use a simple web request as well in case BITS isn't available # Invoke-WebRequest -Uri $url -OutFile $filepath -UseBasicParsing
# open video in associated player Invoke-Item-Path$filepath }