├── .gitattributes ├── README.md ├── LICENSE ├── PSGalleryDrive.psm1 └── PSGalleryDrive.psd1 /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PSGalleryDrive 2 | 3 | This is only a proof of concept and is not the final version of the implementation. I am working on a design that will give more flexibility. If you have any thoughts on what you want to see, feel free to create an issue in this repository. 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ravikanth C 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /PSGalleryDrive.psm1: -------------------------------------------------------------------------------- 1 | using namespace Microsoft.PowerShell.SHiPS 2 | 3 | [SHiPSProvider(UseCache = $true)] 4 | class PSGRoot : SHiPSDirectory 5 | { 6 | # Default constructor 7 | PSGRoot([string]$name):base($name) 8 | { 9 | } 10 | 11 | [object[]] GetChildItem() 12 | { 13 | $obj = @() 14 | 15 | $obj += [DSCResources]::new('DSCResources') 16 | $obj += [Modules]::new('Modules') 17 | $obj += [Scripts]::new('Scripts') 18 | return $obj 19 | } 20 | } 21 | 22 | #region DSC Resources 23 | [SHiPSProvider(UseCache = $true)] 24 | class DSCResources : SHiPSDirectory 25 | { 26 | DSCResources([string]$name):base($name) 27 | { 28 | } 29 | 30 | [object[]] GetChildItem() 31 | { 32 | $obj = @() 33 | 34 | # Find all DSC Resources - Use Find-DscResource cmdlet 35 | $dscResources = (Find-DscResource).Name | Sort-Object 36 | foreach ($resource in $dscResources) { 37 | $obj += [PSDSCResource]::new($resource) 38 | } 39 | return $obj 40 | } 41 | } 42 | 43 | [SHiPSProvider(UseCache = $true)] 44 | class PSDSCResource : SHiPSDirectory 45 | { 46 | PSDSCResource([string]$name):base($name) 47 | { 48 | } 49 | 50 | [object[]] GetChildItem() 51 | { 52 | try 53 | { 54 | return Find-DscResource -Name $this.name -ErrorAction Stop 55 | } 56 | 57 | catch 58 | { 59 | throw $_ 60 | } 61 | } 62 | } 63 | #endregion 64 | 65 | #region modules 66 | [SHiPSProvider(UseCache = $true)] 67 | class Modules : SHiPSDirectory 68 | { 69 | Modules([string]$name):base($name) 70 | { 71 | } 72 | 73 | [object[]] GetChildItem() 74 | { 75 | $obj = @() 76 | 77 | # Find all DSC Resources - Use Find-Module cmdlet 78 | $modules = (Find-Module).Name | Sort-Object 79 | foreach ($module in $modules) { 80 | $obj += [PSModule]::new($module) 81 | } 82 | return $obj 83 | } 84 | } 85 | 86 | [SHiPSProvider(UseCache = $true)] 87 | class PSModule : SHiPSDirectory 88 | { 89 | PSModule([string]$name):base($name) 90 | { 91 | } 92 | 93 | [object[]] GetChildItem() 94 | { 95 | try 96 | { 97 | return Find-Module -Name $this.name -ErrorAction Stop 98 | } 99 | 100 | catch 101 | { 102 | throw $_ 103 | } 104 | } 105 | } 106 | #endregion 107 | 108 | #region scripts 109 | [SHiPSProvider(UseCache = $true)] 110 | class Scripts : SHiPSDirectory 111 | { 112 | Scripts([string]$name):base($name) 113 | { 114 | } 115 | 116 | [object[]] GetChildItem() 117 | { 118 | $obj = @() 119 | 120 | # Find all scripts - Use Find-Script cmdlet 121 | $scripts = (Find-Script).Name | Sort-Object 122 | foreach ($script in $scripts) { 123 | $obj += [PSScript]::new($script) 124 | } 125 | return $obj 126 | } 127 | } 128 | 129 | [SHiPSProvider(UseCache = $true)] 130 | class PSScript : SHiPSDirectory 131 | { 132 | PSScript([string]$name):base($name) 133 | { 134 | } 135 | 136 | [object[]] GetChildItem() 137 | { 138 | try 139 | { 140 | return Find-Script -Name $this.name -ErrorAction Stop 141 | } 142 | 143 | catch 144 | { 145 | throw $_ 146 | } 147 | } 148 | } 149 | #endregion -------------------------------------------------------------------------------- /PSGalleryDrive.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for module 'PSGalleryDrive' 3 | # 4 | # Generated by: Ravikanth Chaganti 5 | # 6 | # Generated on: 11/21/2017 7 | # 8 | 9 | @{ 10 | 11 | # Script module or binary module file associated with this manifest. 12 | RootModule = '.\PSGalleryDrive.psm1' 13 | 14 | # Version number of this module. 15 | ModuleVersion = '0.1.0' 16 | 17 | # Supported PSEditions 18 | # CompatiblePSEditions = @() 19 | 20 | # ID used to uniquely identify this module 21 | GUID = '2fd81943-9454-4be4-88be-83eca55948a2' 22 | 23 | # Author of this module 24 | Author = 'Ravikanth Chaganti' 25 | 26 | # Company or vendor of this module 27 | CompanyName = 'PowerShell Magazine' 28 | 29 | # Copyright statement for this module 30 | Copyright = '(c) PowerShell Magazine. All rights reserved.' 31 | 32 | # Description of the functionality provided by this module 33 | Description = 'PSGalleryDrive is a SHiPS based PowerShell provider to simplify navigation and discovery of PowerShell modules, DSC Resources, and scripts hosted on PowerShell Gallery.' 34 | 35 | # Minimum version of the Windows PowerShell engine required by this module 36 | PowerShellVersion = '5.1' 37 | 38 | # Name of the Windows PowerShell host required by this module 39 | # PowerShellHostName = '' 40 | 41 | # Minimum version of the Windows PowerShell host required by this module 42 | # PowerShellHostVersion = '' 43 | 44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 45 | # DotNetFrameworkVersion = '' 46 | 47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 48 | # CLRVersion = '' 49 | 50 | # Processor architecture (None, X86, Amd64) required by this module 51 | # ProcessorArchitecture = '' 52 | 53 | # Modules that must be imported into the global environment prior to importing this module 54 | RequiredModules = @('SHiPS') 55 | 56 | # Assemblies that must be loaded prior to importing this module 57 | # RequiredAssemblies = @() 58 | 59 | # Script files (.ps1) that are run in the caller's environment prior to importing this module. 60 | # ScriptsToProcess = @() 61 | 62 | # Type files (.ps1xml) to be loaded when importing this module 63 | # TypesToProcess = @() 64 | 65 | # Format files (.ps1xml) to be loaded when importing this module 66 | #FormatsToProcess = 'CimPSDrive.formats.ps1xml' 67 | 68 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 69 | # NestedModules = @() 70 | 71 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 72 | #FunctionsToExport = 'Connect-CIM', 'Disconnect-CIM' 73 | 74 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 75 | CmdletsToExport = @() 76 | 77 | # Variables to export from this module 78 | # VariablesToExport = @() 79 | 80 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 81 | AliasesToExport = @() 82 | 83 | # DSC resources to export from this module 84 | # DscResourcesToExport = @() 85 | 86 | # List of all modules packaged with this module 87 | # ModuleList = @() 88 | 89 | # List of all files packaged with this module 90 | # FileList = @() 91 | 92 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 93 | PrivateData = @{ 94 | 95 | PSData = @{ 96 | 97 | # Tags applied to this module. These help with module discovery in online galleries. 98 | Tags = 'Navigation','SHiPS','PSGet','PowerShell Gallery' 99 | 100 | # A URL to the license for this module. 101 | LicenseUri = 'https://github.com/rchaganti/PSGalleryDrive/blob/master/LICENSE' 102 | 103 | # A URL to the main website for this project. 104 | ProjectUri = 'https://github.com/rchaganti/PSGalleryDrive' 105 | 106 | # A URL to an icon representing this module. 107 | # IconUri = '' 108 | 109 | # ReleaseNotes of this module 110 | ReleaseNotes = 'https://github.com/rchaganti/PSGalleryDrive/blob/master/Readme.md' 111 | # ExternalModuleDependencies = '' 112 | 113 | } # End of PSData hashtable 114 | 115 | } # End of PrivateData hashtable 116 | 117 | # HelpInfo URI of this module 118 | # HelpInfoURI = '' 119 | 120 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 121 | # DefaultCommandPrefix = '' 122 | 123 | } 124 | --------------------------------------------------------------------------------