2016-07-27 00:54:31 +02:00
|
|
|
|
#region find, install, update, uninstall the PowerShell scripts from an online repository.
|
|
|
|
|
# Value: equivalent of pypi
|
|
|
|
|
|
|
|
|
|
# List of PowerShellGet commands
|
|
|
|
|
Get-Command -Module PowerShellGet
|
|
|
|
|
|
|
|
|
|
# Discover PowerShell Scripts
|
|
|
|
|
Find-Script
|
|
|
|
|
Find-Script -Name Start-Demo
|
|
|
|
|
|
|
|
|
|
# Save scripts to a specified location
|
|
|
|
|
Save-Script Start-Demo -Repository PSGallery -Path /tmp
|
|
|
|
|
Get-ChildItem -Path /tmp/Start-Demo.ps1
|
|
|
|
|
|
|
|
|
|
# Install a script to the common scripts location
|
|
|
|
|
Find-Script -Name Start-Demo -Repository PSGallery | Install-Script
|
|
|
|
|
Get-InstalledScript
|
|
|
|
|
|
|
|
|
|
# Install another script to show the update functionality
|
|
|
|
|
Install-Script Fabrikam-Script -RequiredVersion 1.0
|
|
|
|
|
Get-InstalledScript
|
|
|
|
|
Get-InstalledScript Fabrikam-Script | Format-List *
|
|
|
|
|
|
|
|
|
|
# Update the installed scripts
|
|
|
|
|
Update-Script -WhatIf
|
|
|
|
|
Update-Script
|
|
|
|
|
Get-InstalledScript
|
|
|
|
|
|
|
|
|
|
# Uninstall a script file
|
|
|
|
|
Uninstall-Script Fabrikam-Script -Verbose
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2016-07-29 14:23:11 +02:00
|
|
|
|
#region Using PowerShellGet find and install modules
|
2016-07-27 00:54:31 +02:00
|
|
|
|
|
|
|
|
|
# Value: equivalent of pypi
|
|
|
|
|
# Look for all the modules we'll be demoing today
|
|
|
|
|
Find-Module -Tag 'PowerShellCore_Demo'
|
|
|
|
|
|
2016-07-29 14:23:11 +02:00
|
|
|
|
# Save module to specified location
|
|
|
|
|
Save-Module -Tag 'PowerShellCore_Demo' -Path /tmp
|
|
|
|
|
|
2016-07-27 00:54:31 +02:00
|
|
|
|
# Pipe this to Install-Module to install them
|
|
|
|
|
Find-Module -Tag 'PowerShellCore_Demo' | Install-Module -Verbose
|
|
|
|
|
Get-InstalledModule
|
|
|
|
|
|
2016-07-29 14:23:11 +02:00
|
|
|
|
# Update all installed modules
|
|
|
|
|
Update-Module
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Using PowerShellGet with tags
|
2016-07-27 00:54:31 +02:00
|
|
|
|
|
|
|
|
|
# Look for all the scripts we'll be demoing today
|
|
|
|
|
Find-Script -Tag 'PowerShellCore_Demo'
|
|
|
|
|
|
|
|
|
|
# Pipe this to Install-Script to install them
|
|
|
|
|
Find-Script -Tag 'PowerShellCore_Demo' | Install-Script -Verbose
|
|
|
|
|
Get-InstalledScript
|
|
|
|
|
|
|
|
|
|
#endregion
|
2016-07-29 14:23:11 +02:00
|
|
|
|
|
|
|
|
|
#region Working with PowerShellGet repositories
|
|
|
|
|
|
|
|
|
|
# List available PS repositories
|
|
|
|
|
Get-PSRepository
|
|
|
|
|
|
|
|
|
|
# Register a new private feed
|
|
|
|
|
Register-PSRepository -Name "myPrivateGallery" –SourceLocation "https://www.myget.org/F/powershellgetdemo/api/v2" -PublishLocation "https://www.myget.org/F/powershellgetdemo/api/v2/Packages" -InstallationPolicy Trusted
|
|
|
|
|
|
|
|
|
|
# Change the trust level for a repositories
|
|
|
|
|
Set-PSRepository -Name "myPrivateGallery" -InstallationPolicy "Untrusted"
|
|
|
|
|
|
|
|
|
|
# Remove a private feed
|
|
|
|
|
Unregister-PSRepository -Name "myPrivateGallery"
|
|
|
|
|
|
|
|
|
|
#endregion
|