Introducing
IntroducingWindowsServer2016_ebook
IntroducingWindowsServer2016_ebook
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
VERBOSE: Importing function 'Unregister-PSRepository'.<br />
VERBOSE: Importing function 'Update-Module'.<br />
VERBOSE: Importing function 'Update-ModuleManifest'.<br />
VERBOSE: Importing function 'Update-Script'.<br />
VERBOSE: Importing function 'Update-ScriptFileInfo'.<br />
VERBOSE: Importing alias 'fimo'.<br />
VERBOSE: Importing alias 'inmo'.<br />
VERBOSE: Importing alias 'pumo'.<br />
VERBOSE: Importing alias 'upmo'.<br />
Using the Verbose switch with the Import-Module cmdlet displays all imported functions, cmdlets, and<br />
aliases on the console. There are eight functions, two variables, and four aliases available in this<br />
module.<br />
The first time you use the PowershellGet cmdlet, it verifies the installation of NuGet on the machine. If<br />
NuGet is not installed, a confirmation message box appears, as follows:<br />
PowershellGet requires NuGet_anycpu.exe to interact with NuGet-based galleries. NuGet_anycpu.exe must be<br />
available in 'C:\ProgramData\OneGet\ProviderAssemblies' or<br />
'C:\Users\\AppData\Local\OneGet\ProviderAssemblies'. For more information about NuGet, see<br />
http://www.nuget.org. Do you want PowershellGet to download NuGet_anycpu.exe now?<br />
Clicking Yes downloads and installs NuGet on the machine.<br />
The cmdlets provided by PowershellGet are divided into two broad categories: modules and<br />
repository cmdlets. PowershellGet provides cmdlets for finding, installing, publishing, and updating<br />
modules from the repository. It also provides cmdlets for reading current repository settings as well as<br />
updating, registering, and unregistering them.<br />
Two repositories are available by default: PSGallery and MSPSGallery. PowershellGet uses the NuGet<br />
provider to connect to these repositories. Running Get-PSRepository displays all existing repositories<br />
on the machine.<br />
PS C:\users\me>> Get-PSRepository<br />
Name SourceLocation OneGetProvider InstallationPolicy<br />
---- -------------- -------------- ------------------<br />
PSGallery https://msconfiggallery.cloudapp.net/api/v2/ NuGet Untrusted<br />
MSPSGallery http://www.microsoft.com/ NuGet Trusted<br />
Running the Get-PSRepository cmdlet with a repository name displays configurations related to that<br />
repository.<br />
PS C:\WINDOWS\system32> get-PSRepository -name PSGallery |Format-list *<br />
Name<br />
: PSGallery<br />
SourceLocation<br />
: https://www.powershellgallery.com/api/v2/<br />
Trusted<br />
: False<br />
Registered<br />
: True<br />
InstallationPolicy : Untrusted<br />
PackageManagementProvider : NuGet<br />
PublishLocation<br />
: https://www.powershellgallery.com/api/v2/package/<br />
ScriptSourceLocation : https://www.powershellgallery.com/api/v2/items/psscrip<br />
ScriptPublishLocation : https://www.powershellgallery.com/api/v2/package/<br />
ProviderOptions : {}<br />
Within the output, SourceLocation indicates the URL of the repository location,<br />
PackageManagementProvider identifies the package provider used to connect to the repository (NuGet<br />
in this case), Trusted indicates whether the repository is trusted, and PublishLocation shows the URL<br />
used for submission of modules.<br />
Running the Set-PSRepository cmdlet sets the configuration values of a repository. For example, the<br />
Set-PSRepository cmdlet that follows changes the configuration value Untrusted to Trusted for the<br />
PSGallery repository. After changing a value, you can review the new configuration by running the<br />
Get-PSRepository cmdlet.<br />
PS C:\Users\me> Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted<br />
PS C:\Users\me> Get-PSRepository<br />
134 CHAPTER 5 | Systems management