├── .github └── ISSUE_TEMPLATE │ ├── -bug----bug-report.md │ └── -feature----feature-request.md ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── PSP-Inventory ├── PSP-Inventory.psd1 ├── PSP-Inventory.psm1 ├── docs │ ├── Get-PspCertificate.md │ ├── Get-PspDiskInfo.md │ ├── Get-PspLocalGroup.md │ ├── Get-PspLocalUser.md │ ├── Get-PspNicInfo.md │ ├── Get-PspOSInfo.md │ ├── Get-PspScheduledTask.md │ ├── Get-PspSecurityUpdate.md │ ├── Get-PspServerRole.md │ ├── Get-PspSoftware.md │ └── Get-PspSysInfo.md ├── en-US │ └── PSP-Inventory-help.xml ├── formats │ ├── certinfo.format.ps1xml │ ├── diskinfo.format.ps1xml │ ├── localgroup.format.ps1xml │ ├── localuser.format.ps1xml │ ├── nicinfo.format.ps1xml │ ├── osinfo.format.ps1xml │ ├── schedtask.format.ps1xml │ ├── securityupdate.format.ps1xml │ ├── sysinfo.format.ps1xml │ └── vminfo.format.ps1xml ├── private │ ├── Convert-ChassisType.ps1 │ ├── Convert-DomainRole.ps1 │ ├── Convert-NetworkStatus.ps1 │ ├── Convert-UserFlag.ps1 │ ├── ConvertTo-SID.ps1 │ ├── _GetCertInfo.ps1 │ ├── _GetDiskInfo.ps1 │ ├── _GetLocalGroup.ps1 │ ├── _GetLocalGroupMember.ps1 │ ├── _GetLocalUser.ps1 │ ├── _GetNicInfo.ps1 │ ├── _GetOSInfo.ps1 │ ├── _GetRoleInfo.ps1 │ ├── _GetSoftwareInfo.ps1 │ ├── _GetSysInfo.ps1 │ ├── _GetUpdateInfo.ps1 │ └── _GetVMInfo.ps1 └── public │ ├── Get-PspCertificate.ps1 │ ├── Get-PspDiskInfo.ps1 │ ├── Get-PspLocalGroup.ps1 │ ├── Get-PspLocalUser.ps1 │ ├── Get-PspNicInfo.ps1 │ ├── Get-PspOSInfo.ps1 │ ├── Get-PspScheduledTask.ps1 │ ├── Get-PspSecurityUpdate.ps1 │ ├── Get-PspServerRole.ps1 │ ├── Get-PspSoftware.ps1 │ ├── Get-PspSysInfo.ps1 │ └── Get-PspVMInfo.ps1 ├── README.md ├── build.ps1 ├── psake.ps1 └── tests ├── External.Help.Tests.ps1 ├── Module.Help.ps1 └── UnitTests.Tests.ps1 /.github/ISSUE_TEMPLATE/-bug----bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "[BUG] - Bug report" 3 | about: Create a report to help us improve 4 | title: "[BUG] - Bug report" 5 | labels: bug 6 | assignees: powershellpr0mpt 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior. 15 | Please make use of the code blocks in case you want to reference actual PowerShell code for readability 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Versions** 24 | - PowerShell version 25 | - Module version 26 | - OS Version 27 | 28 | **Additional context** 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/-feature----feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "[FEATURE] - Feature request" 3 | about: Suggest an idea for this project 4 | title: "[FEATURE] - Feature request" 5 | labels: enhancement 6 | assignees: powershellpr0mpt 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _bin 2 | _zip 3 | _testresults 4 | *.psdeploy.ps1 -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) 6 | and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). 7 | 8 | ## [1.0.8] - 2019-03-19 9 | 10 | ### Fixed 11 | 12 | - [Issue #45](https://github.com/powershellpr0mpt/PSP-Inventory/issues/45) - `Get-PspLocalUser` and `Get-PspLocalGroup` give errors on PSSession - continued... Finally confirmed fixed this time :) 13 | 14 | ### Added 15 | 16 | - [Issue #46](https://github.com/powershellpr0mpt/PSP-Inventory/issues/46) - Better error handling for improperly formatted dates in software registry when using `Get-PspSoftware` 17 | 18 | --- 19 | 20 | ## [1.0.7] - 2019-03-16 21 | 22 | ### Fixed 23 | 24 | - [Issue #42](https://github.com/powershellpr0mpt/PSP-Inventory/issues/42) - `Get-PspLocalUser` and `Get-PspLocalGroup` give errors on PSSession 25 | 26 | --- 27 | 28 | ## [1.0.6] - 2019-03-16 29 | 30 | ### Changed 31 | 32 | - [Issue #40](https://github.com/powershellpr0mpt/PSP-Inventory/issues/40) - `Get-PspSecurityUpdate` performance VERY slow 33 | 34 | --- 35 | 36 | ## [1.0.5] - 2019-03-16 37 | 38 | ### Fixed 39 | 40 | - [Issue #36](https://github.com/powershellpr0mpt/PSP-Inventory/issues/36) - `Get-PspVMInfo` produces error when not a Hyper-V VM 41 | - [Issue #37](https://github.com/powershellpr0mpt/PSP-Inventory/issues/37) - `Get-PspOSInfo` can give error on Productkey when not available 42 | - [Issue #38](https://github.com/powershellpr0mpt/PSP-Inventory/issues/38) - `Get-PspLocalGroup` broken after update 1.0.4 when using PSSession 43 | 44 | --- 45 | 46 | ## [1.0.4] - 2019-03-16 47 | 48 | ### Added 49 | 50 | - [Issue #34](https://github.com/powershellpr0mpt/PSP-Inventory/issues/34) - Added extra information to be gathered. Includes a new cmdlet: `Get-PspVMInfo` 51 | 52 | --- 53 | 54 | ## [1.0.3] - 2019-03-15 55 | 56 | ### Fixed 57 | 58 | - Similar to [Issue #25](https://github.com/powershellpr0mpt/PSP-Inventory/issues/26) - Added a check to see if `Get-PspLocalGroup` is run on a Domain Controller or not. 59 | 60 | --- 61 | 62 | ## [1.0.2] - 2019-03-14 63 | 64 | ### Fixed 65 | 66 | - [Issue #32](https://github.com/powershellpr0mpt/PSP-Inventory/issues/32) - Page file information not displayed when multiple page files configured 67 | 68 | --- 69 | 70 | ## [1.0.1] - 2019-03-14 71 | 72 | ### Added 73 | 74 | - [Issue #24](https://github.com/powershellpr0mpt/PSP-Inventory/issues/25) - Added a check to see if `Get-PspServerRole` is run on a workstation or not. 75 | - [Issue #25](https://github.com/powershellpr0mpt/PSP-Inventory/issues/26) - Added a check to see if `Get-PspLocalUser` is run on a Domain Controller or not. 76 | 77 | ### Fixed 78 | 79 | - [Issue #24](https://github.com/powershellpr0mpt/PSP-Inventory/issues/24) - Correctly displays Hyper-V VMs as virtual machines now 80 | 81 | --- 82 | 83 | ## [1.0.0] - 2019-03-12 84 | 85 | ### BREAKING 86 | 87 | - [Issue #1](https://github.com/powershellpr0mpt/PSP-Inventory/issues/1) - Added a Psp Prefix to cmdlets. 88 | Do note that old cmdlets are no longer available for use and current scripts using this module will have to be changed or aliases will have to be created. 89 | This does fix the issue of conflicting cmdlet such as `Get-LocalUser` which caused the module to require the `AllowClobber` parameter before it could be installed. 90 | 91 | ### Added 92 | 93 | - [Issue #2](https://github.com/powershellpr0mpt/PSP-Inventory/issues/2) - Added external help. 94 | - [Issue #10](https://github.com/powershellpr0mpt/PSP-Inventory/issues/10) - Added native PsProvider access to registry. 95 | - [Issue #13](https://github.com/powershellpr0mpt/PSP-Inventory/issues/13) - Added CIM/PSSession functionality for improved performance. 96 | 97 | ### Fixed 98 | 99 | - [Issue #7](https://github.com/powershellpr0mpt/PSP-Inventory/issues/7) - Due to new help system, new Pester test has been made to check availability of help. 100 | 101 | --- 102 | 103 | ## [0.9.2] - 2019-03-05 104 | 105 | ### Changed 106 | 107 | - [Issue #8](https://github.com/powershellpr0mpt/PSP-Inventory/issues/8) - No longer exports private functions. 108 | - [Issue #9](https://github.com/powershellpr0mpt/PSP-Inventory/issues/9) - InventoryDate property is now a proper `[datetime]` object. 109 | 110 | ### Fixed 111 | 112 | - [Issue #17](https://github.com/powershellpr0mpt/PSP-Inventory/issues/17) - Various cmdlets now include custom display formats. 113 | - [Issue #18](https://github.com/powershellpr0mpt/PSP-Inventory/issues/18) - The WinZIP build task now creates an archive as expected. when all tests are successful. Getting the tests to run successful is still an issue though, see [Issue #7](https://github.com/powershellpr0mpt/PSP-Inventory/issues/7). 114 | 115 | --- 116 | 117 | ## [0.9.1] - 2019-03-01 118 | 119 | ### Changed 120 | 121 | - [Issue #3](https://github.com/powershellpr0mpt/PSP-Inventory/pull/3) - ComputerName property always displays in uppercase. 122 | - `Get-RemoteCertificate` includes more properties [Subject/HasPrivateKey]. 123 | - Changed Notes and Link URLs to https. 124 | 125 | ### Fixed 126 | 127 | - [Issue #5](https://github.com/powershellpr0mpt/PSP-Inventory/pull/5) - Inventory date on `Get-SecurityUpdate` and `Get-Software` incorrect. 128 | 129 | --- 130 | 131 | ## [0.9.0] - 2019-02-28 132 | 133 | ### Added 134 | 135 | - Working Pester tests. 136 | 137 | ### Changed 138 | 139 | - Updated build scripts. 140 | - Updated Changelog and Contribution documentation. 141 | 142 | ### Removed 143 | 144 | - Old scripts that were no longer used/required. 145 | 146 | ### Known Issues 147 | 148 | - Pester test for help files on `Get-RemoteCertificate` script provides an error on the StoreLocation and StoreName type. 149 | 150 | --- 151 | 152 | ## [Unreleased] 153 | 154 | ### Changed 155 | 156 | - Cleaning up folder structure and moving all parts to the correct location. 157 | - Adding comment based help for all public functions. -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | Contributions to PSP-Inventory are highly encouraged and desired. 3 | Below are some guidelines that will help make the process as smooth as possible. 4 | 5 | # Getting Started 6 | * Make sure you have a [GitHub account](https://github.com/users/sign_in). 7 | * Submit a new issue, assuming one does not already exist. 8 | * Clearly describe the issue including steps to reproduce when it is a bug. 9 | * Make sure you fill in the earliest version that you know has the issue. 10 | * Fork the repository on to your GitHub account. 11 | 12 | # Suggesting Enhancements 13 | I want to know what you think is missing from PSP-Inventory and how it can be made better. 14 | * When submitting an issue for an enhancement, please be as clear as possible about why you think the enhancement is needed and what the benefit of it would be. 15 | 16 | # Making Changes 17 | * From your fork of the repository, create a topic branch where work on your change will take place. 18 | * To quickly create a topic branch based on master; `git checkout -b my_contribution master`. 19 | Please avoid working directly on the `master` branch. 20 | * Make commits of logical units. 21 | * Check for unnecessary whitespace with `git diff --check` before committing. 22 | * Please follow the prevailing code conventions in the repository. 23 | Differences in style make the code harder to understand for everyone. 24 | * Make sure your commit messages are in the proper format. 25 | ```text 26 | Add more cowbell to Get-Something.ps1 27 | 28 | The functionaly of Get-Something would be greatly improved if there was a little 29 | more 'pizzazz' added to it. I propose a cowbell. Adding more cowbell has been 30 | shown in studies to both increase one's mojo, and cement one's status 31 | as a rock legend. 32 | ``` 33 | 34 | * Make sure you have added all the necessary Pester tests for your changes. 35 | * Run _all_ PESTER tests in the module to assure nothing else was accidentally broken. 36 | 37 | # Documentation 38 | If you find any of the following in the documentation, please file an issue - the maintainers consider these to be bugs as serious as bugs in the code: 39 | 40 | + Grammatical errors 41 | + Dead links 42 | + Examples that don't function as stated 43 | + Explanations that you don't understand on fewer than three read-throughs 44 | + Language that is too wordy or not clear enough 45 | + Concepts that aren't explained fully 46 | + Questions you have that aren't answered by the docs 47 | + Others we haven't thought of yet 48 | 49 | # Submitting Changes 50 | * Push your changes to a topic branch in your fork of the repository. 51 | * Submit a merge request to the main repository. 52 | * Once the merge request has been reviewed and accepted, it will be merged with the master branch. 53 | * Celebrate 54 | 55 | # Additional Resources 56 | * [General GitHub documentation](https://help.github.com/) 57 | * [GitHub forking documentation](https://guides.github.com/activities/forking/) 58 | * [GitHub pull request documentation](https://help.github.com/send-pull-requests/) 59 | * [GitHub Flow guide](https://guides.github.com/introduction/flow/) 60 | * [GitHub's guide to contributing to open source projects](https://guides.github.com/activities/contributing-to-open-source/) 61 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Robert Prust 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. 22 | -------------------------------------------------------------------------------- /PSP-Inventory/PSP-Inventory.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for module 'PSP-Inventory' 3 | # 4 | # Generated by: Robert Prust 5 | # 6 | # Changed on: 20-03-2019 7 | # 8 | 9 | @{ 10 | 11 | # Script module or binary module file associated with this manifest. 12 | RootModule = 'PSP-Inventory.psm1' 13 | 14 | # Version number of this module. 15 | ModuleVersion = '1.0.8' 16 | 17 | # Supported PSEditions 18 | # CompatiblePSEditions = @() 19 | 20 | # ID used to uniquely identify this module 21 | GUID = '778139c7-99bd-41c5-9bcf-ec32fe7e7d56' 22 | 23 | # Author of this module 24 | Author = 'Robert Prust' 25 | 26 | # Company or vendor of this module 27 | CompanyName = 'powershellpr0mpt.com' 28 | 29 | # Copyright statement for this module 30 | Copyright = '(c) Robert Prust. All rights reserved.' 31 | 32 | # Description of the functionality provided by this module 33 | Description = 'Inventorise your environment through PowerShell' 34 | 35 | # Minimum version of the PowerShell engine required by this module 36 | # PowerShellVersion = '' 37 | 38 | # Name of the PowerShell host required by this module 39 | # PowerShellHostName = '' 40 | 41 | # Minimum version of the 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 = @() 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 = @() 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 = '*' 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 = @('Inventory', 'powershellpr0mpt', 'PSEdition_Desktop', 'Windows') 99 | 100 | # A URL to the license for this module. 101 | LicenseUri = 'https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/LICENSE.md' 102 | 103 | # A URL to the main website for this project. 104 | ProjectUri = 'https://github.com/powershellpr0mpt/PSP-Inventory' 105 | 106 | # A URL to an icon representing this module. 107 | # IconUri = '' 108 | 109 | # ReleaseNotes of this module 110 | ReleaseNotes = 'https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/CHANGELOG.md' 111 | 112 | } # End of PSData hashtable 113 | 114 | } # End of PrivateData hashtable 115 | 116 | # HelpInfo URI of this module 117 | # HelpInfoURI = '' 118 | 119 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 120 | # DefaultCommandPrefix = '' 121 | 122 | } -------------------------------------------------------------------------------- /PSP-Inventory/PSP-Inventory.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | .DESCRIPTION 3 | Loader file for functions in PSP-Inventory module. 4 | 5 | .NOTES 6 | 7 | Name: PSP-Inventory 8 | Author: Robert Prust 9 | Version: 1.0.8 10 | Blog: https://powershellpr0mpt.com 11 | 12 | .LINK 13 | https://powershellpr0mpt.com 14 | #> 15 | 16 | #Function Loader 17 | [cmdletbinding()] 18 | param() 19 | Write-Verbose $PSScriptRoot 20 | 21 | Write-Verbose 'Import Private Functions' 22 | $Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue ) 23 | 24 | Write-Verbose 'Import Public Functions' 25 | $Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue ) 26 | 27 | #Dot source the files 28 | Foreach ($Function in @($Public + $Private)) { 29 | Try { 30 | . $Function.FullName 31 | } 32 | Catch { 33 | Write-Error -Message "Failed to import function $($Function.FullName): $_" 34 | } 35 | } 36 | 37 | ### Export Public functions 38 | Export-ModuleMember -Function $Public.Basename 39 | -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspCertificate.md: -------------------------------------------------------------------------------- 1 | --- 2 | External Help File: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | Online Version: https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/docs/Get-PspCertificate.md 5 | Schema: 2.0.0 6 | --- 7 | 8 | # Get-PspCertificate 9 | 10 | ## SYNOPSIS 11 | 12 | Get certification information for local or remote machines. 13 | 14 | ## SYNTAX 15 | 16 | ### Computer (Default) 17 | 18 | ```powershell 19 | Get-PspCertificate [[-ComputerName] ] [-Credential ] [[-StoreName] ] 20 | [[-StoreLocation] ] [] 21 | ``` 22 | 23 | ### Session 24 | 25 | ```powershell 26 | Get-PspCertificate [[-PSSession] ] [[-StoreName] ] [[-StoreLocation] ] 27 | [] 28 | ``` 29 | 30 | ## DESCRIPTION 31 | 32 | Get certification information for local or remote machines. 33 | Allows you to specify exactly which store you want to query. 34 | 35 | ## EXAMPLES 36 | 37 | ### EXAMPLE 1 38 | 39 | ```powershell 40 | PS C:\> Get-PspCertificate -ComputerName 'CONTOSO-SRV01' 41 | 42 | ComputerName NotAfter NotBefore Subject Thumbprint 43 | ------------ -------- --------- ------- ---------- 44 | CONTOSO-SRV01 9-9-2038 11:31:44 14-9-2018 11:31:44 CN=127.0.0.1 BA03E7647E61F2562A... 45 | CONTOSO-SRV01 23-11-2038 15:49:59 28-11-2018 15:49:59 CN=127.0.0.1 B9EDE957C09C462C68... 46 | CONTOSO-SRV01 12-3-2019 22:46:38 11-3-2019 22:41:38 CN=1d55f591-ad2c-43dd-abef-ff7e3e6a6f51, DC=dbddf572-f118-4b32-8139-dc6cd6bae4f8 69CD7B0FB0D244E4FA... 47 | CONTOSO-SRV01 3-12-2028 14:02:53 3-12-2018 13:32:53 CN=1d55f591-ad3c-43dd-abef-ff7e3e6a6f51 28165F4FDE3E0FAA24... 48 | CONTOSO-SRV01 3-12-2019 14:02:58 3-12-2018 13:52:58 CN=a8b24bcf-6f4c-4b8c-907e-37acb9b15d3b 0F674857164B0D4197... 49 | ``` 50 | 51 | Gets the certification information for CONTOSO-SRV01 using the 'My' storename and 'LocalMachine' storelocation, displaying the default properties. 52 | 53 | ## PARAMETERS 54 | 55 | ### -ComputerName 56 | 57 | Provide the computername(s) to query. 58 | Using this parameter will create a temporary PSSession to obtain the information if available. 59 | If PowerShell remoting is not available, it will try and obtain the information through .NET. 60 | Default value is the local machine. 61 | 62 | ```yaml 63 | Type: String[] 64 | Parameter Sets: Computer 65 | Aliases: CN 66 | Required: False 67 | Position: 1 68 | Default value: $env:COMPUTERNAME 69 | Accept pipeline input: True (ByPropertyName, ByValue) 70 | Accept wildcard characters: False 71 | ``` 72 | 73 | ### -Credential 74 | 75 | Provide the credentials for the PowerShell remoting session to be created if current credentials are not sufficient. 76 | 77 | ```yaml 78 | Type: PSCredential 79 | Parameter Sets: Computer 80 | Aliases: 81 | Required: False 82 | Position: Named 83 | Default value: None 84 | Accept pipeline input: False 85 | Accept wildcard characters: False 86 | ``` 87 | 88 | ### -PSSession 89 | 90 | Provide the PowerShell remoting session object to query if this is already available. 91 | Once the information has been gathered, the PowerShell session will remain available for further use. 92 | 93 | ```yaml 94 | Type: PSSession[] 95 | Parameter Sets: Session 96 | Aliases: Session 97 | Required: False 98 | Position: 1 99 | Default value: None 100 | Accept pipeline input: True (ByValue) 101 | Accept wildcard characters: False 102 | ``` 103 | 104 | ### -StoreName 105 | 106 | Provide the StoreName to query. 107 | Default value is the 'My' name. 108 | 109 | ```yaml 110 | Type: StoreName 111 | Parameter Sets: (All) 112 | Aliases: 113 | Accepted values: AddressBook, AuthRoot, CertificateAuthority, Disallowed, My, Root, TrustedPeople, TrustedPublisher 114 | Required: False 115 | Position: 2 116 | Default value: My 117 | Accept pipeline input: False 118 | Accept wildcard characters: False 119 | ``` 120 | 121 | ### -StoreLocation 122 | 123 | Provide the Certification store to query. 124 | Default value is the 'LocalMachine' store. 125 | 126 | ```yaml 127 | Type: StoreLocation 128 | Parameter Sets: (All) 129 | Aliases: 130 | Accepted values: CurrentUser, LocalMachine 131 | Required: False 132 | Position: 3 133 | Default value: LocalMachine 134 | Accept pipeline input: False 135 | Accept wildcard characters: False 136 | ``` 137 | 138 | ### CommonParameters 139 | 140 | This cmdlet supports the common parameters: 141 | -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 142 | For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 143 | 144 | ## INPUTS 145 | 146 | ## OUTPUTS 147 | 148 | ### PSP.Inventory.Certificate 149 | 150 | ## NOTES 151 | 152 | Name: Get-PspCertificate.ps1 153 | Author: Robert Prüst 154 | Module: PSP-Inventory 155 | DateCreated: 22-02-2019 156 | DateModified: 11-03-2019 157 | Blog: https://powershellpr0mpt.com 158 | 159 | ## RELATED LINKS 160 | 161 | [https://powershellpr0mpt.com](https://powershellpr0mpt.com) -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspDiskInfo.md: -------------------------------------------------------------------------------- 1 | --- 2 | External Help File: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | Online Version: https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/docs/Get-PspDiskInfo.md 5 | Schema: 2.0.0 6 | --- 7 | 8 | # Get-PspDiskInfo 9 | 10 | ## SYNOPSIS 11 | 12 | Get Disk information for local or remote machines. 13 | 14 | ## SYNTAX 15 | 16 | ### Computer (Default) 17 | 18 | ```powershell 19 | Get-PspDiskInfo [[-ComputerName] ] [-Credential ] [] 20 | ``` 21 | 22 | ### Session 23 | 24 | ```powershell 25 | Get-PspDiskInfo [[-CimSession] ] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | Get Disk information for local or remote machines. 31 | Will query Disks, partitions and volumes to obtain as much information as possible. 32 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 33 | If there's already a CIM session available, this can also be used to obtain the data. 34 | 35 | ## EXAMPLES 36 | 37 | ### EXAMPLE 1 38 | 39 | ```powershell 40 | PS C:\> Get-PspDiskInfo -ComputerName 'CONTOSO-SRV01','CONTOSO-WEB01' 41 | 42 | ComputerName DriveLetter FileSystem TotalSizeGB FreeSizeGB UsedSizeGB 43 | ------------ ----------- ---------- ----------- ---------- ---------- 44 | CONTOSO-SRV01 C: NTFS 50 38.81 11.19 45 | CONTOSO-WEB01 C: NTFS 49.36 41.81 7.55 46 | ``` 47 | 48 | Gets the disk information for CONTOSO-SRV01 and CONTOSO-WEB01 by creating a temporary CIM session, displaying the default properties. 49 | 50 | ### EXAMPLE 2 51 | 52 | ```powershell 53 | PS C:\> $CimSession = New-CimSession -ComputerName 'CONTOSO-SRV02' 54 | PS C:\> Get-PspDiskInfo -CimSession $CimSession 55 | 56 | ComputerName DriveLetter FileSystem TotalSizeGB FreeSizeGB UsedSizeGB 57 | ------------ ----------- ---------- ----------- ---------- ---------- 58 | CONTOSO-SRV02 C: NTFS 50 38.81 11.19 59 | ``` 60 | 61 | Creates a CIM session for CONTOSO-SRV02 and uses this session to get the Disk information from this machine. 62 | The session can then be re-used for other cmdlets in order to get more information. 63 | Re-using the session provides performance benefits. 64 | 65 | ## PARAMETERS 66 | 67 | ### -ComputerName 68 | 69 | Provide the computername(s) to query. 70 | This will create a new CIM session which will be removed once the information has been gathered. 71 | Default value is the local machine. 72 | 73 | ```yaml 74 | Type: String[] 75 | Parameter Sets: Computer 76 | Aliases: CN 77 | Required: False 78 | Position: 1 79 | Default value: $env:COMPUTERNAME 80 | Accept pipeline input: True (ByPropertyName, ByValue) 81 | Accept wildcard characters: False 82 | ``` 83 | 84 | ### -Credential 85 | 86 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 87 | 88 | ```yaml 89 | Type: PSCredential 90 | Parameter Sets: Computer 91 | Aliases: 92 | Required: False 93 | Position: Named 94 | Default value: None 95 | Accept pipeline input: False 96 | Accept wildcard characters: False 97 | ``` 98 | 99 | ### -CimSession 100 | 101 | Provide the CIM session object to query if this is already available. 102 | Once the information has been gathered, the CIM session will remain available for further use. 103 | 104 | ```yaml 105 | Type: CimSession[] 106 | Parameter Sets: Session 107 | Aliases: Session 108 | Required: False 109 | Position: 1 110 | Default value: None 111 | Accept pipeline input: True (ByValue) 112 | Accept wildcard characters: False 113 | ``` 114 | 115 | ### CommonParameters 116 | 117 | This cmdlet supports the common parameters: 118 | -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 119 | For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 120 | 121 | ## INPUTS 122 | 123 | ## OUTPUTS 124 | 125 | ### PSP.Inventory.Disk 126 | 127 | ## NOTES 128 | 129 | Name: Get-PspDiskInfo.ps1 130 | Author: Robert Prüst 131 | Module: PSP-Inventory 132 | DateCreated: 22-12-2018 133 | DateModified: 11-03-2019 134 | Blog: https://powershellpr0mpt.com 135 | 136 | ## RELATED LINKS 137 | 138 | [https://powershellpr0mpt.com](https://powershellpr0mpt.com) -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspLocalGroup.md: -------------------------------------------------------------------------------- 1 | --- 2 | External Help File: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | Online Version: https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/docs/Get-PspLocalGroup.md 5 | Schema: 2.0.0 6 | --- 7 | 8 | # Get-PspLocalGroup 9 | 10 | ## SYNOPSIS 11 | 12 | Get all local groups for local or remote machines. 13 | 14 | ## SYNTAX 15 | 16 | ### Computer (Default) 17 | 18 | ```powershell 19 | Get-PspLocalGroup [[-ComputerName] ] [-Credential ] [] 20 | ``` 21 | 22 | ### Session 23 | 24 | ```powershell 25 | Get-PspLocalGroup [[-PSSession] ] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | Get all local groups for local or remote machines. 31 | Provides extra information such as members. 32 | 33 | ## EXAMPLES 34 | 35 | ### EXAMPLE 1 36 | 37 | ```powershell 38 | PS C:\> Get-PspLocalGroup -ComputerName CONTOSO-HV01 39 | 40 | ComputerName GroupName GroupType 41 | ------------ --------- --------- 42 | CONTOSO-HV01 Access Control Assistance Operators Local Group 43 | CONTOSO-HV01 Administrators Local Group 44 | CONTOSO-HV01 Backup Operators Local Group 45 | CONTOSO-HV01 Certificate Service DCOM Access Local Group 46 | CONTOSO-HV01 Cryptographic Operators Local Group 47 | CONTOSO-HV01 Distributed COM Users Local Group 48 | CONTOSO-HV01 Event Log Readers Local Group 49 | CONTOSO-HV01 Guests Local Group 50 | CONTOSO-HV01 Hyper-V Administrators Local Group 51 | CONTOSO-HV01 IIS_IUSRS Local Group 52 | CONTOSO-HV01 Network Configuration Operators Local Group 53 | CONTOSO-HV01 Performance Log Users Local Group 54 | CONTOSO-HV01 Performance Monitor Users Local Group 55 | CONTOSO-HV01 Power Users Local Group 56 | CONTOSO-HV01 Print Operators Local Group 57 | CONTOSO-HV01 RDS Endpoint Servers Local Group 58 | CONTOSO-HV01 RDS Management Servers Local Group 59 | CONTOSO-HV01 RDS Remote Access Servers Local Group 60 | CONTOSO-HV01 Remote Desktop Users Local Group 61 | CONTOSO-HV01 Remote Management Users Local Group 62 | CONTOSO-HV01 Replicator Local Group 63 | CONTOSO-HV01 Storage Replica Administrators Local Group 64 | CONTOSO-HV01 System Managed Accounts Group Local Group 65 | CONTOSO-HV01 Users Local Group 66 | ``` 67 | 68 | Gets all local groups for the machine CONTOSO-HV01, displaying the default properties. 69 | 70 | ### EXAMPLE 2 71 | 72 | ```powershell 73 | PS C:\> Get-PspLocalGroup -ComputerName CONTOSO-APP01 | Where-Object {$_.GroupName -eq 'Administrators'} | Select-Object ComputerName,GroupName,Members 74 | 75 | ComputerName GroupName Members 76 | ------------ --------- ------- 77 | CONTOSO-APP01 Administrators Administrator 78 | ``` 79 | 80 | Shows you all the members of the Administrators group on CONTOSO-APP01. 81 | 82 | ## PARAMETERS 83 | 84 | ### -ComputerName 85 | 86 | Provide the computername(s) to query. 87 | Using this parameter will create a temporary PSSession to obtain the information if available. 88 | If PowerShell remoting is not available, it will try and obtain the information through ADSI. 89 | Default value is the local machine. 90 | 91 | ```yaml 92 | Type: String[] 93 | Parameter Sets: Computer 94 | Aliases: CN 95 | Required: False 96 | Position: 1 97 | Default value: $env:COMPUTERNAME 98 | Accept pipeline input: True (ByPropertyName, ByValue) 99 | Accept wildcard characters: False 100 | ``` 101 | 102 | ### -Credential 103 | 104 | Provide the credentials for the PowerShell remoting session to be created if current credentials are not sufficient. 105 | 106 | ```yaml 107 | Type: PSCredential 108 | Parameter Sets: Computer 109 | Aliases: 110 | Required: False 111 | Position: Named 112 | Default value: None 113 | Accept pipeline input: False 114 | Accept wildcard characters: False 115 | ``` 116 | 117 | ### -PSSession 118 | 119 | Provide the PowerShell remoting session object to query if this is already available. 120 | Once the information has been gathered, the PowerShell session will remain available for further use. 121 | 122 | ```yaml 123 | Type: PSSession[] 124 | Parameter Sets: Session 125 | Aliases: Session 126 | Required: False 127 | Position: 1 128 | Default value: None 129 | Accept pipeline input: True (ByValue) 130 | Accept wildcard characters: False 131 | ``` 132 | 133 | ### CommonParameters 134 | 135 | This cmdlet supports the common parameters: 136 | -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 137 | For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 138 | 139 | ## INPUTS 140 | 141 | ## OUTPUTS 142 | 143 | ### PSP.Inventory.LocalGroup 144 | 145 | ## NOTES 146 | 147 | Name: Get-PspLocalGroup.ps1 148 | Author: Robert Prüst 149 | Module: PSP-Inventory 150 | DateCreated: 20-02-2019 151 | DateModified: 12-03-2019 152 | Blog: https://powershellpr0mpt.com 153 | 154 | ## RELATED LINKS 155 | 156 | [https://powershellpr0mpt.com](https://powershellpr0mpt.com) -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspLocalUser.md: -------------------------------------------------------------------------------- 1 | --- 2 | External Help File: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | Online Version: https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/docs/Get-PspLocalUser.md 5 | Schema: 2.0.0 6 | --- 7 | 8 | # Get-PspLocalUser 9 | 10 | ## SYNOPSIS 11 | 12 | Get all local users for local or remote machines. 13 | 14 | ## SYNTAX 15 | 16 | ### Computer (Default) 17 | 18 | ```powershell 19 | Get-PspLocalUser [[-ComputerName] ] [-Credential ] [] 20 | ``` 21 | 22 | ### Session 23 | 24 | ```powershell 25 | Get-PspLocalUser [[-PSSession] ] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | Get all local users for local or remote machines. 31 | Provides extra information about the actual user based on the user's settings. 32 | 33 | ## EXAMPLES 34 | 35 | ### EXAMPLE 1 36 | 37 | ```powershell 38 | PS C:\> Get-PspLocalUser -ComputerName CONTOSO-SRV01 39 | 40 | ComputerName UserName LastLogin 41 | ------------ -------- --------- 42 | CONTOSO-SRV01 Administrator 3/12/2019 8:47:17 AM 43 | CONTOSO-SRV01 DefaultAccount 44 | CONTOSO-SRV01 Guest 45 | ``` 46 | 47 | Gets the local users for CONTOSO-SRV01, displaying the default properties. 48 | 49 | ## PARAMETERS 50 | 51 | ### -ComputerName 52 | 53 | Provide the computername(s) to query. 54 | Using this parameter will create a temporary PSSession to obtain the information if available. 55 | If PowerShell remoting is not available, it will try and obtain the information through ADSI. 56 | Default value is the local machine. 57 | 58 | ```yaml 59 | Type: String[] 60 | Parameter Sets: Computer 61 | Aliases: CN 62 | Required: False 63 | Position: 1 64 | Default value: $env:COMPUTERNAME 65 | Accept pipeline input: True (ByPropertyName, ByValue) 66 | Accept wildcard characters: False 67 | ``` 68 | 69 | ### -Credential 70 | 71 | Provide the credentials for the PowerShell remoting session to be created if current credentials are not sufficient. 72 | 73 | ```yaml 74 | Type: PSCredential 75 | Parameter Sets: Computer 76 | Aliases: 77 | Required: False 78 | Position: Named 79 | Default value: None 80 | Accept pipeline input: False 81 | Accept wildcard characters: False 82 | ``` 83 | 84 | ### -PSSession 85 | 86 | Provide the PowerShell remoting session object to query if this is already available. 87 | Once the information has been gathered, the PowerShell session will remain available for further use. 88 | 89 | ```yaml 90 | Type: PSSession[] 91 | Parameter Sets: Session 92 | Aliases: Session 93 | Required: False 94 | Position: 1 95 | Default value: None 96 | Accept pipeline input: True (ByValue) 97 | Accept wildcard characters: False 98 | ``` 99 | 100 | ### CommonParameters 101 | 102 | This cmdlet supports the common parameters: 103 | -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 104 | For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 105 | 106 | ## INPUTS 107 | 108 | ## OUTPUTS 109 | 110 | ### PSP.Inventory.LocalUser 111 | 112 | ## NOTES 113 | 114 | Name: Get-PspLocalUser.ps1 115 | Author: Robert Prüst 116 | Module: PSP-Inventory 117 | DateCreated: 20-02-2019 118 | DateModified: 12-03-2019 119 | Blog: https://powershellpr0mpt.com 120 | 121 | ## RELATED LINKS 122 | 123 | [https://powershellpr0mpt.com](https://powershellpr0mpt.com) -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspNicInfo.md: -------------------------------------------------------------------------------- 1 | --- 2 | External Help File: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | Online Version: https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/docs/Get-PspNicInfo.md 5 | Schema: 2.0.0 6 | --- 7 | 8 | # Get-PspNicInfo 9 | 10 | ## SYNOPSIS 11 | 12 | Get Network adapter information for local or remote machines. 13 | 14 | ## SYNTAX 15 | 16 | ### Computer (Default) 17 | 18 | ```powershell 19 | Get-PspNicInfo [[-ComputerName] ] [-Credential ] [-Drivers] [] 20 | ``` 21 | 22 | ### Session 23 | 24 | ```powershell 25 | Get-PspNicInfo [[-CimSession] ] [-Drivers] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | Get Network adapter information for local or remote machines. 31 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 32 | If there's already a CIM session available, this can also be used to obtain the data. 33 | 34 | ## EXAMPLES 35 | 36 | ### EXAMPLE 1 37 | 38 | ```powershell 39 | PS C:\> Get-PspNicInfo -ComputerName CONTOSO-SRV01,CONTOSO-SRV02 40 | 41 | ComputerName Alias Index IPAddress Status 42 | ------------ ----- ----- --------- ------ 43 | CONTOSO-SRV01 Ethernet 1 {192.168.14.6, fe80::a438:7d49:4f12:b000} Connected 44 | CONTOSO-SRV02 Ethernet 1 {192.168.14.7, fe80::31f3:d92a:a4b9:e3a8} Connected 45 | ``` 46 | 47 | Gets network adapter information for both CONTOSO-SRV01 and CONTOSO-SRV02, displaying the default properties. 48 | 49 | ## PARAMETERS 50 | 51 | ### -ComputerName 52 | 53 | Provide the computername(s) to query. 54 | This will create a new CIM session which will be removed once the information has been gathered. 55 | Default value is the local machine. 56 | 57 | ```yaml 58 | Type: String[] 59 | Parameter Sets: Computer 60 | Aliases: CN 61 | Required: False 62 | Position: 1 63 | Default value: $env:COMPUTERNAME 64 | Accept pipeline input: True (ByPropertyName, ByValue) 65 | Accept wildcard characters: False 66 | ``` 67 | 68 | ### -Credential 69 | 70 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 71 | 72 | ```yaml 73 | Type: PSCredential 74 | Parameter Sets: Computer 75 | Aliases: 76 | Required: False 77 | Position: Named 78 | Default value: None 79 | Accept pipeline input: False 80 | Accept wildcard characters: False 81 | ``` 82 | 83 | ### -CimSession 84 | 85 | Provide the CIM session object to query if this is already available. 86 | Once the information has been gathered, the CIM session will remain available for further use. 87 | 88 | ```yaml 89 | Type: CimSession[] 90 | Parameter Sets: Session 91 | Aliases: Session 92 | Required: False 93 | Position: 1 94 | Default value: None 95 | Accept pipeline input: True (ByValue) 96 | Accept wildcard characters: False 97 | ``` 98 | 99 | ### -Drivers 100 | 101 | Switch parameter. 102 | If activated will try and obtain the driver information for the adapter. 103 | Do note that this will substantially increase time required. 104 | 105 | ```yaml 106 | Type: SwitchParameter 107 | Parameter Sets: (All) 108 | Aliases: 109 | Required: False 110 | Position: Named 111 | Default value: False 112 | Accept pipeline input: False 113 | Accept wildcard characters: False 114 | ``` 115 | 116 | ### CommonParameters 117 | 118 | This cmdlet supports the common parameters: 119 | -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 120 | For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 121 | 122 | ## INPUTS 123 | 124 | ## OUTPUTS 125 | 126 | ### PSP.Inventory.NIC 127 | 128 | ## NOTES 129 | 130 | Name: Get-PspNicInfo.ps1 131 | Author: Robert Prüst 132 | Module: PSP-Inventory 133 | DateCreated: 20-12-2018 134 | DateModified: 12-03-2019 135 | Blog: https://powershellpr0mpt.com 136 | 137 | ## RELATED LINKS 138 | 139 | [https://powershellpr0mpt.com](https://powershellpr0mpt.com) -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspOSInfo.md: -------------------------------------------------------------------------------- 1 | --- 2 | External Help File: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | Online Version: https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/docs/Get-PspOSInfo.md 5 | Schema: 2.0.0 6 | --- 7 | 8 | # Get-PspOSInfo 9 | 10 | ## SYNOPSIS 11 | 12 | Get Operating System information for local or remote machines. 13 | 14 | ## SYNTAX 15 | 16 | ### Computer (Default) 17 | 18 | ```powershell 19 | Get-PspOSInfo [[-ComputerName] ] [-Credential ] [] 20 | ``` 21 | 22 | ### Session 23 | 24 | ```powershell 25 | Get-PspOSInfo [[-CimSession] ] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | Get Operating System information for local or remote machines. 31 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 32 | If there's already a CIM session available, this can also be used to obtain the data. 33 | 34 | ## EXAMPLES 35 | 36 | ### EXAMPLE 1 37 | 38 | ```powershell 39 | PS C:\> Get-PspOSInfo -ComputerName CONTOSO-SRV01,CONTOSO-SRV02 40 | 41 | ComputerName Caption Version OSArchitecture LastReboot 42 | ------------ ------- ------- -------------- ---------- 43 | CONTOSO-SRV01 Microsoft Windows Server 2016 Standard 10.0.14393 64-bit 3/4/2019 1:41:07 PM 44 | CONTOSO-SRV02 Microsoft Windows Server 2019 Standard 10.0.17763 64-bit 3/4/2019 1:41:25 PM 45 | ``` 46 | 47 | Gets Operating system information for CONTOSO-SRV01 and CONTOSO-SRV02, displaying the default properties. 48 | 49 | ### EXAMPLE 2 50 | 51 | ```powershell 52 | PS C:\> Get-PspOSInfo -ComputerName CONTOSO-WEB01 | Format-List 53 | 54 | ComputerName : CONTOSO-WEB01 55 | Caption : Microsoft Windows Server 2016 Standard 56 | Version : 10.0.14393 57 | ServicePack : 0.0 58 | ProductKey : 59 | LastReboot : 3/4/2019 1:41:07 PM 60 | OSArchitecture : 64-bit 61 | TimeZone : (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna 62 | PageFile : 63 | PageFileSizeGB : 0 64 | InventoryDate : 3/12/2019 9:56:50 AM 65 | ``` 66 | 67 | Gets the Operating system information for CONTOSO-WEB01 and shows all collected properties. 68 | 69 | ## PARAMETERS 70 | 71 | ### -ComputerName 72 | 73 | Provide the computername(s) to query. 74 | This will create a new CIM session which will be removed once the information has been gathered. 75 | Default value is the local machine. 76 | 77 | ```yaml 78 | Type: String[] 79 | Parameter Sets: Computer 80 | Aliases: CN 81 | Required: False 82 | Position: 1 83 | Default value: $env:COMPUTERNAME 84 | Accept pipeline input: True (ByPropertyName, ByValue) 85 | Accept wildcard characters: False 86 | ``` 87 | 88 | ### -Credential 89 | 90 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 91 | 92 | ```yaml 93 | Type: PSCredential 94 | Parameter Sets: Computer 95 | Aliases: 96 | Required: False 97 | Position: Named 98 | Default value: None 99 | Accept pipeline input: False 100 | Accept wildcard characters: False 101 | ``` 102 | 103 | ### -CimSession 104 | 105 | Provide the CIM session object to query if this is already available. 106 | Once the information has been gathered, the CIM session will remain available for further use. 107 | 108 | ```yaml 109 | Type: CimSession[] 110 | Parameter Sets: Session 111 | Aliases: Session 112 | Required: False 113 | Position: 1 114 | Default value: None 115 | Accept pipeline input: True (ByValue) 116 | Accept wildcard characters: False 117 | ``` 118 | 119 | ### CommonParameters 120 | 121 | This cmdlet supports the common parameters: 122 | -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 123 | For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 124 | 125 | ## INPUTS 126 | 127 | ## OUTPUTS 128 | 129 | ### PSP.Inventory.OperatingSystemInfo 130 | 131 | ## NOTES 132 | 133 | Name: Get-PspOSInfo.ps1 134 | Author: Robert Prüst 135 | Module: PSP-Inventory 136 | DateCreated: 20-02-2019 137 | DateModified: 12-03-2019 138 | Blog: https://powershellpr0mpt.com 139 | 140 | ## RELATED LINKS 141 | 142 | [https://powershellpr0mpt.com](https://powershellpr0mpt.com) -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspScheduledTask.md: -------------------------------------------------------------------------------- 1 | --- 2 | External Help File: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | Online Version: https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/docs/Get-PspScheduledTask.md 5 | Schema: 2.0.0 6 | --- 7 | 8 | # Get-PspScheduledTask 9 | 10 | ## SYNOPSIS 11 | 12 | Get Scheduled task information for local or remote machines. 13 | 14 | ## SYNTAX 15 | 16 | ```powershell 17 | Get-PspScheduledTask [[-ComputerName] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | 22 | Get Scheduled task information for local or remote machines. 23 | Will get all scheduled tasks in the root folder. 24 | 25 | ## EXAMPLES 26 | 27 | ### EXAMPLE 1 28 | 29 | ```powershell 30 | PS C:\> Get-PspScheduledTask -ComputerName CONTOSO-SRV01,CONTOSO-WEB01,CONTOSO-APP01 31 | 32 | ComputerName Task Enabled State LastResult 33 | ------------ ---- ------- ----- ---------- 34 | CONTOSO-SRV01 Optimize Start Menu Cache Files-S-1-5-21-2130384611-3847849876-2318412143-500 False Disabled Successfully completed 35 | CONTOSO-WEB01 notepad False Disabled Successfully completed 36 | CONTOSO-APP01 GoogleUpdateTaskMachineCore True Ready Successfully completed 37 | CONTOSO-APP01 GoogleUpdateTaskMachineUA True Ready Successfully completed 38 | ``` 39 | 40 | Gets the Scheduled Tasks for CONTOSO-SRV01, CONTOSO-WEB01 and CONTOSO-APP01, displaying the default properties. 41 | 42 | ## PARAMETERS 43 | 44 | ### -ComputerName 45 | 46 | Provide the computername(s) to query. 47 | Default value is the local machine. 48 | 49 | ```yaml 50 | Type: String[] 51 | Parameter Sets: (All) 52 | Aliases: CN 53 | Required: False 54 | Position: 1 55 | Default value: $env:COMPUTERNAME 56 | Accept pipeline input: True (ByPropertyName, ByValue) 57 | Accept wildcard characters: False 58 | ``` 59 | 60 | ### CommonParameters 61 | 62 | This cmdlet supports the common parameters: 63 | -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 64 | For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 65 | 66 | ## INPUTS 67 | 68 | ## OUTPUTS 69 | 70 | ### PSP.Inventory.ScheduledTask 71 | 72 | ## NOTES 73 | 74 | Name: Get-PspScheduledTask.ps1 75 | Author: Robert Prüst 76 | Module: PSP-Inventory 77 | DateCreated: 23-02-2019 78 | DateModified: 12-03-2019 79 | Blog: https://powershellpr0mpt.com 80 | 81 | ## RELATED LINKS 82 | 83 | [https://powershellpr0mpt.com](https://powershellpr0mpt.com) -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspSecurityUpdate.md: -------------------------------------------------------------------------------- 1 | --- 2 | External Help File: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | Online Version: https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/docs/Get-PspSecurityUpdate.md 5 | Schema: 2.0.0 6 | --- 7 | 8 | # Get-PspSecurityUpdate 9 | 10 | ## SYNOPSIS 11 | Get all the security update information for local or remote machines. 12 | 13 | ## SYNTAX 14 | 15 | ### Computer (Default) 16 | 17 | ```powershell 18 | Get-PspSecurityUpdate [[-ComputerName] ] [-Credential ] [] 19 | ``` 20 | 21 | ### Session 22 | 23 | ```powershell 24 | Get-PspSecurityUpdate [[-CimSession] ] [] 25 | ``` 26 | 27 | ## DESCRIPTION 28 | 29 | Get all the security update information for local or remote machines. 30 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 31 | If there's already a CIM session available, this can also be used to obtain the data. 32 | 33 | ## EXAMPLES 34 | 35 | ### EXAMPLE 1 36 | 37 | ```powershell 38 | PS C:\> Get-PspSecurityUpdate -ComputerName CONTOSO-SRV01,CONTOSO-SRV02 39 | 40 | ComputerName Type KBFile InstallDate 41 | ------------ ---- ------ ----------- 42 | CONTOSO-SRV01 Update KB4049065 2/2/2018 12:00:00 AM 43 | CONTOSO-SRV01 Security Update KB4048953 2/2/2018 12:00:00 AM 44 | CONTOSO-SRV02 Update KB4464455 10/29/2018 12:00:00 AM 45 | ``` 46 | 47 | Gets the installed security updates for CONTOSO-SRV01 and CONTOSO-SRV02, displaying the default properties. 48 | 49 | ## PARAMETERS 50 | 51 | ### -ComputerName 52 | 53 | Provide the computername(s) to query. 54 | This will create a new CIM session which will be removed once the information has been gathered. 55 | Default value is the local machine. 56 | 57 | ```yaml 58 | Type: String[] 59 | Parameter Sets: Computer 60 | Aliases: CN 61 | Required: False 62 | Position: 1 63 | Default value: $env:COMPUTERNAME 64 | Accept pipeline input: True (ByPropertyName, ByValue) 65 | Accept wildcard characters: False 66 | ``` 67 | 68 | ### -Credential 69 | 70 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 71 | 72 | ```yaml 73 | Type: PSCredential 74 | Parameter Sets: Computer 75 | Aliases: 76 | Required: False 77 | Position: Named 78 | Default value: None 79 | Accept pipeline input: False 80 | Accept wildcard characters: False 81 | ``` 82 | 83 | ### -CimSession 84 | 85 | Provide the CIM session object to query if this is already available. 86 | Once the information has been gathered, the CIM session will remain available for further use. 87 | 88 | ```yaml 89 | Type: CimSession[] 90 | Parameter Sets: Session 91 | Aliases: Session 92 | Required: False 93 | Position: 1 94 | Default value: None 95 | Accept pipeline input: True (ByValue) 96 | Accept wildcard characters: False 97 | ``` 98 | 99 | ### CommonParameters 100 | 101 | This cmdlet supports the common parameters: 102 | -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 103 | For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 104 | 105 | ## INPUTS 106 | 107 | ## OUTPUTS 108 | 109 | ### PSP.Inventory.SecurityUpdate 110 | 111 | ## NOTES 112 | 113 | Name: Get-PspSecurityUpdate.ps1 114 | Author: Robert Prüst 115 | Module: PSP-Inventory 116 | DateCreated: 21-02-2019 117 | DateModified: 12-03-2019 118 | Blog: https://powershellpr0mpt.com 119 | 120 | ## RELATED LINKS 121 | 122 | [https://powershellpr0mpt.com](https://powershellpr0mpt.com) -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspServerRole.md: -------------------------------------------------------------------------------- 1 | --- 2 | External Help File: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | Online Version: https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/docs/Get-PspServerRole.md 5 | Schema: 2.0.0 6 | --- 7 | 8 | # Get-PspServerRole 9 | 10 | ## SYNOPSIS 11 | 12 | Get Server Roles for local or remote machines. 13 | 14 | ## SYNTAX 15 | 16 | ### Computer (Default) 17 | 18 | ```powershell 19 | Get-PspServerRole [[-ComputerName] ] [-Credential ] [] 20 | ``` 21 | 22 | ### Session 23 | 24 | ```powershell 25 | Get-PspServerRole [[-CimSession] ] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | Get Server Roles for local or remote machines. 31 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 32 | If there's already a CIM session available, this can also be used to obtain the data. 33 | 34 | ## EXAMPLES 35 | 36 | ### EXAMPLE 1 37 | 38 | ```powershell 39 | PS C:\> Get-PspServerRole -ComputerName CONTOSO-SRV01,CONTOSO-SRV02 40 | 41 | ComputerName RoleId Name InventoryDate 42 | ------------ ------ ---- ------------- 43 | CONTOSO-SRV01 481 File and Storage Services 3/12/2019 10:18:40 AM 44 | CONTOSO-SRV01 487 SMB 1.0/CIFS File Sharing Support 3/12/2019 10:18:40 AM 45 | CONTOSO-SRV01 418 .NET Framework 4.6 3/12/2019 10:18:40 AM 46 | CONTOSO-SRV01 466 .NET Framework 4.6 Features 3/12/2019 10:18:40 AM 47 | CONTOSO-SRV01 420 WCF Services 3/12/2019 10:18:40 AM 48 | CONTOSO-SRV01 425 TCP Port Sharing 3/12/2019 10:18:40 AM 49 | CONTOSO-SRV01 412 Windows PowerShell 5.1 3/12/2019 10:18:40 AM 50 | CONTOSO-SRV01 417 Windows PowerShell 3/12/2019 10:18:40 AM 51 | CONTOSO-SRV01 482 Storage Services 3/12/2019 10:18:40 AM 52 | CONTOSO-SRV01 1003 Windows Defender 3/12/2019 10:18:40 AM 53 | CONTOSO-SRV01 1020 Windows Defender Features 3/12/2019 10:18:40 AM 54 | CONTOSO-SRV01 340 WoW64 Support 3/12/2019 10:18:40 AM 55 | CONTOSO-SRV02 481 File and Storage Services 3/12/2019 10:18:40 AM 56 | CONTOSO-SRV02 418 .NET Framework 4.7 3/12/2019 10:18:41 AM 57 | CONTOSO-SRV02 466 .NET Framework 4.7 Features 3/12/2019 10:18:41 AM 58 | CONTOSO-SRV02 420 WCF Services 3/12/2019 10:18:41 AM 59 | CONTOSO-SRV02 425 TCP Port Sharing 3/12/2019 10:18:41 AM 60 | CONTOSO-SRV02 412 Windows PowerShell 5.1 3/12/2019 10:18:41 AM 61 | CONTOSO-SRV02 417 Windows PowerShell 3/12/2019 10:18:41 AM 62 | CONTOSO-SRV02 482 Storage Services 3/12/2019 10:18:41 AM 63 | CONTOSO-SRV02 1043 System Data Archiver 3/12/2019 10:18:41 AM 64 | CONTOSO-SRV02 1003 Windows Defender Antivirus 3/12/2019 10:18:41 AM 65 | CONTOSO-SRV02 340 WoW64 Support 3/12/2019 10:18:41 AM 66 | ``` 67 | 68 | Gets the installed server roles for CONTOSO-SRV01 and CONTOSO-SRV02. 69 | 70 | ## PARAMETERS 71 | 72 | ### -ComputerName 73 | 74 | Provide the computername(s) to query. 75 | This will create a new CIM session which will be removed once the information has been gathered. 76 | Default value is the local machine. 77 | 78 | ```yaml 79 | Type: String[] 80 | Parameter Sets: Computer 81 | Aliases: CN 82 | Required: False 83 | Position: 1 84 | Default value: $env:COMPUTERNAME 85 | Accept pipeline input: True (ByPropertyName, ByValue) 86 | Accept wildcard characters: False 87 | ``` 88 | 89 | ### -Credential 90 | 91 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 92 | 93 | ```yaml 94 | Type: PSCredential 95 | Parameter Sets: Computer 96 | Aliases: 97 | Required: False 98 | Position: Named 99 | Default value: None 100 | Accept pipeline input: False 101 | Accept wildcard characters: False 102 | ``` 103 | 104 | ### -CimSession 105 | 106 | Provide the CIM session object to query if this is already available. 107 | Once the information has been gathered, the CIM session will remain available for further use. 108 | 109 | ```yaml 110 | Type: CimSession[] 111 | Parameter Sets: Session 112 | Aliases: Session 113 | Required: False 114 | Position: 1 115 | Default value: None 116 | Accept pipeline input: True (ByValue) 117 | Accept wildcard characters: False 118 | ``` 119 | 120 | ### CommonParameters 121 | 122 | This cmdlet supports the common parameters: 123 | -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 124 | For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 125 | 126 | ## INPUTS 127 | 128 | ## OUTPUTS 129 | 130 | ### PSP.Inventory.ServerRole 131 | 132 | ## NOTES 133 | 134 | Name: Get-PspServerRole.ps1 135 | Author: Robert Prüst 136 | Module: PSP-Inventory 137 | DateCreated: 22-12-2018 138 | DateModified: 12-03-2019 139 | Blog: https://powershellpr0mpt.com 140 | 141 | ## RELATED LINKS 142 | 143 | [https://powershellpr0mpt.com](https://powershellpr0mpt.com) -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspSoftware.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | online version: http://powershellpr0mpt.com 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-PspSoftware 9 | 10 | ## SYNOPSIS 11 | Get the installed software for local or remote machines. 12 | 13 | ## SYNTAX 14 | 15 | ### Computer (Default) 16 | ``` 17 | Get-PspSoftware [[-ComputerName] ] [-Credential ] [] 18 | ``` 19 | 20 | ### Session 21 | ``` 22 | Get-PspSoftware [[-PSSession] ] [] 23 | ``` 24 | 25 | ## DESCRIPTION 26 | Get the installed software for local or remote machines. 27 | Will try and access the required data through a PowerShell remoting session, but in case this fails reverts to RemoteRegistry. 28 | This does however require RemoteRegistry to be enabled on the machine. 29 | Will look for both x86 and x64 installed paths. 30 | 31 | ## EXAMPLES 32 | 33 | ### EXAMPLE 1 34 | ``` 35 | Get-PspSoftware -ComputerName CONTOSO-SRV01,CONTOSO-WEB01,CONTOSO-APP01 36 | ``` 37 | 38 | ComputerName : CONTOSO-SRV01 39 | DisplayName : Google Chrome 40 | Version : 72.0.3626.121 41 | InstallDate : 3/11/2019 12:00:00 AM 42 | Publisher : Google LLC 43 | UninstallString : MsiExec.exe /X{0C8D8E7A-485A-39D9-82C9-DF0955BE2A57} 44 | InstallLocation : 45 | InstallSource : C:\Users\Administrator\AppData\Local\Temp\1\Temp1_GoogleChromeEnterpriseBundle64.zip\Installers\ 46 | HelpLink : 47 | EstimatedSizeMB : 54.5 48 | InventoryDate : 3/12/2019 10:25:45 AM 49 | 50 | ComputerName : CONTOSO-SRV01 51 | DisplayName : Google Update Helper 52 | Version : 1.3.33.23 53 | InstallDate : 3/11/2019 12:00:00 AM 54 | Publisher : Google Inc. 55 | UninstallString : MsiExec.exe /I{60EC980A-BDA2-4CB6-A427-B07A5498B4CA} 56 | InstallLocation : 57 | InstallSource : C:\Program Files (x86)\Google\Update\1.3.33.23\ 58 | HelpLink : 59 | EstimatedSizeMB : 0.04 60 | InventoryDate : 3/12/2019 10:25:45 AM 61 | 62 | ComputerName : CONTOSO-WEB01 63 | DisplayName : VLC media player 64 | Version : 3.0.6 65 | InstallDate : 66 | Publisher : VideoLAN 67 | UninstallString : "C:\Program Files (x86)\VideoLAN\VLC\uninstall.exe" 68 | InstallLocation : C:\Program Files (x86)\VideoLAN\VLC 69 | InstallSource : 70 | HelpLink : 71 | EstimatedSize : 0 72 | InventoryDate : 3/12/2019 10:25:45 AM 73 | 74 | ComputerName : CONTOSO-APP01 75 | DisplayName : Notepad++ (32-bit x86) 76 | Version : 7.6.4 77 | InstallDate : 78 | Publisher : Notepad++ Team 79 | UninstallString : C:\Program Files (x86)\Notepad++\uninstall.exe 80 | InstallLocation : 81 | InstallSource : 82 | HelpLink : 83 | EstimatedSize : 4.35 84 | InventoryDate : 3/12/2019 10:25:45 AM 85 | 86 | Gets the installed software for CONTOSO-SRV01, CONTOSO-WEB01 and CONTOSO-APP01. 87 | 88 | ## PARAMETERS 89 | 90 | ### -ComputerName 91 | Provide the computername(s) to query. 92 | Using this parameter will create a temporary PSSession to obtain the information if available. 93 | If PowerShell remoting is not available, it will try and obtain the information through ADSI. 94 | Default value is the local machine. 95 | 96 | ```yaml 97 | Type: String[] 98 | Parameter Sets: Computer 99 | Aliases: CN 100 | 101 | Required: False 102 | Position: 1 103 | Default value: $env:COMPUTERNAME 104 | Accept pipeline input: True (ByPropertyName, ByValue) 105 | Accept wildcard characters: False 106 | ``` 107 | 108 | ### -Credential 109 | Provide the credentials for the PowerShell remoting session to be created if current credentials are not sufficient. 110 | 111 | ```yaml 112 | Type: PSCredential 113 | Parameter Sets: Computer 114 | Aliases: 115 | 116 | Required: False 117 | Position: Named 118 | Default value: None 119 | Accept pipeline input: False 120 | Accept wildcard characters: False 121 | ``` 122 | 123 | ### -PSSession 124 | Provide the PowerShell remoting session object to query if this is already available. 125 | Once the information has been gathered, the PowerShell session will remain available for further use. 126 | 127 | ```yaml 128 | Type: PSSession[] 129 | Parameter Sets: Session 130 | Aliases: Session 131 | 132 | Required: False 133 | Position: 1 134 | Default value: None 135 | Accept pipeline input: True (ByValue) 136 | Accept wildcard characters: False 137 | ``` 138 | 139 | ### CommonParameters 140 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 141 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 142 | 143 | ## INPUTS 144 | 145 | ## OUTPUTS 146 | 147 | ### PSP.Inventory.Software 148 | ## NOTES 149 | Name: Get-PspSoftware.ps1 150 | Author: Robert Prüst 151 | Module: PSP-Inventory 152 | DateCreated: 21-02-2019 153 | DateModified: 12-03-2019 154 | Blog: http://powershellpr0mpt.com 155 | 156 | ## RELATED LINKS 157 | 158 | [http://powershellpr0mpt.com](http://powershellpr0mpt.com) 159 | 160 | -------------------------------------------------------------------------------- /PSP-Inventory/docs/Get-PspSysInfo.md: -------------------------------------------------------------------------------- 1 | --- 2 | External Help File: PSP-Inventory-help.xml 3 | Module Name: PSP-Inventory 4 | Online Version: https://github.com/powershellpr0mpt/PSP-Inventory/blob/master/docs/Get-PspSysInfo.md 5 | Schema: 2.0.0 6 | --- 7 | 8 | # Get-PspSysInfo 9 | 10 | ## SYNOPSIS 11 | 12 | Get System information for local or remote machines. 13 | 14 | ## SYNTAX 15 | 16 | ### Computer (Default) 17 | 18 | ```powershell 19 | Get-PspSysInfo [[-ComputerName] ] [-Credential ] [] 20 | ``` 21 | 22 | ### Session 23 | 24 | ```powershell 25 | Get-PspSysInfo [[-CimSession] ] [] 26 | ``` 27 | 28 | ## DESCRIPTION 29 | 30 | Get System information for local or remote machines. 31 | Will query default information about the actual system, such as CPU & Memory and if it's virtual or physical 32 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 33 | If there's already a CIM session available, this can also be used to obtain the data. 34 | 35 | ## EXAMPLES 36 | 37 | ### EXAMPLE 1 38 | 39 | ```powershell 40 | PS C:\> Get-PspSysInfo -ComputerName CONTOSO-SRV01,CONTOSO-SRV02 41 | 42 | ComputerName Model SerialNumber CPUCores CPULogical MemoryGB 43 | ------------ ----- ------------ -------- ---------- -------- 44 | CONTOSO-SRV01 Virtual Machine 6656-6324-2091-0011-9109-1646-89 1 2 0 45 | CONTOSO-SRV02 Virtual Machine 8945-5393-3426-8378-9495-3257-53 1 2 1 46 | ``` 47 | 48 | Gets the installed server roles for CONTOSO-SRV01 and CONTOSO-SRV02, displaying the default properties. 49 | 50 | ## PARAMETERS 51 | 52 | ### -ComputerName 53 | 54 | Provide the computername(s) to query. 55 | This will create a new CIM session which will be removed once the information has been gathered. 56 | Default value is the local machine. 57 | 58 | ```yaml 59 | Type: String[] 60 | Parameter Sets: Computer 61 | Aliases: CN 62 | Required: False 63 | Position: 1 64 | Default value: $env:COMPUTERNAME 65 | Accept pipeline input: True (ByPropertyName, ByValue) 66 | Accept wildcard characters: False 67 | ``` 68 | 69 | ### -Credential 70 | 71 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 72 | 73 | ```yaml 74 | Type: PSCredential 75 | Parameter Sets: Computer 76 | Aliases: 77 | Required: False 78 | Position: Named 79 | Default value: None 80 | Accept pipeline input: False 81 | Accept wildcard characters: False 82 | ``` 83 | 84 | ### -CimSession 85 | 86 | Provide the CIM session object to query if this is already available. 87 | Once the information has been gathered, the CIM session will remain available for further use. 88 | 89 | ```yaml 90 | Type: CimSession[] 91 | Parameter Sets: Session 92 | Aliases: Session 93 | Required: False 94 | Position: 1 95 | Default value: None 96 | Accept pipeline input: True (ByValue) 97 | Accept wildcard characters: False 98 | ``` 99 | 100 | ### CommonParameters 101 | 102 | This cmdlet supports the common parameters: 103 | -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 104 | For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). 105 | 106 | ## INPUTS 107 | 108 | ## OUTPUTS 109 | 110 | ### PSP.Inventory.SystemInfo 111 | 112 | ## NOTES 113 | 114 | Name: Get-PspSysInfo.ps1 115 | Author: Robert Prüst 116 | Module: PSP-Inventory 117 | DateCreated: 24-02-2019 118 | DateModified: 12-03-2019 119 | Blog: https://powershellpr0mpt.com 120 | 121 | ## RELATED LINKS 122 | 123 | [https://powershellpr0mpt.com](https://powershellpr0mpt.com) -------------------------------------------------------------------------------- /PSP-Inventory/formats/certinfo.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | default 11 | 12 | PSP.Inventory.Certificate 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 18 21 | left 22 | 23 | 24 | 25 | 20 26 | left 27 | 28 | 29 | 30 | 21 31 | left 32 | 33 | 34 | 35 | 15 36 | left 37 | 38 | 39 | 40 | 43 41 | left 42 | 43 | 44 | 45 | 46 | 47 | 51 | 52 | ComputerName 53 | 54 | 55 | NotAfter 56 | 57 | 58 | NotBefore 59 | 60 | 61 | Subject 62 | 63 | 64 | Thumbprint 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /PSP-Inventory/formats/diskinfo.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | default 6 | 7 | PSP.Inventory.Disk 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 15 | left 16 | 17 | 18 | 19 | 14 20 | left 21 | 22 | 23 | 24 | 13 25 | left 26 | 27 | 28 | 29 | 20 30 | left 31 | 32 | 33 | 34 | 19 35 | left 36 | 37 | 38 | 39 | 19 40 | left 41 | 42 | 43 | 44 | 45 | 46 | 47 | ComputerName 48 | 49 | 50 | DriveLetter 51 | 52 | 53 | FileSystem 54 | 55 | 56 | VolumeTotalSizeGB 57 | 58 | 59 | VolumeFreeSizeGB 60 | 61 | 62 | VolumeUsedSizeGB 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /PSP-Inventory/formats/localgroup.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | default 6 | 7 | PSP.Inventory.LocalGroup 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 15 | left 16 | 17 | 18 | 19 | 17 20 | left 21 | 22 | 23 | 24 | 14 25 | left 26 | 27 | 28 | 29 | 30 | 31 | 32 | ComputerName 33 | 34 | 35 | GroupName 36 | 37 | 38 | GroupType 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /PSP-Inventory/formats/localuser.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | default 6 | 7 | PSP.Inventory.LocalUser 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 15 | left 16 | 17 | 18 | 19 | 16 20 | left 21 | 22 | 23 | 24 | 16 25 | left 26 | 27 | 28 | 29 | 30 | 31 | 32 | ComputerName 33 | 34 | 35 | UserName 36 | 37 | 38 | LastLogin 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /PSP-Inventory/formats/nicinfo.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | default 6 | 7 | PSP.Inventory.NIC 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 15 | left 16 | 17 | 18 | 19 | 13 20 | left 21 | 22 | 23 | 24 | 8 25 | left 26 | 27 | 28 | 29 | 8 30 | left 31 | 32 | 33 | 34 | 21 35 | left 36 | 37 | 38 | 39 | 40 | 41 | 42 | ComputerName 43 | 44 | 45 | Alias 46 | 47 | 48 | Index 49 | 50 | 51 | IPAddress 52 | 53 | 54 | Status 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /PSP-Inventory/formats/osinfo.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | default 6 | 7 | PSP.Inventory.OperatingSystemInfo 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 15 | left 16 | 17 | 18 | 19 | 27 20 | left 21 | 22 | 23 | 24 | 13 25 | left 26 | 27 | 28 | 29 | 17 30 | left 31 | 32 | 33 | 34 | 21 35 | left 36 | 37 | 38 | 39 | 40 | 41 | 42 | ComputerName 43 | 44 | 45 | Caption 46 | 47 | 48 | Version 49 | 50 | 51 | OSArchitecture 52 | 53 | 54 | LastReboot 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /PSP-Inventory/formats/schedtask.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | default 6 | 7 | PSP.Inventory.ScheduledTask 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 15 | left 16 | 17 | 18 | 19 | 37 20 | left 21 | 22 | 23 | 24 | 10 25 | left 26 | 27 | 28 | 29 | 8 30 | left 31 | 32 | 33 | 34 | 25 35 | left 36 | 37 | 38 | 39 | 40 | 41 | 42 | ComputerName 43 | 44 | 45 | Task 46 | 47 | 48 | Enabled 49 | 50 | 51 | State 52 | 53 | 54 | LastTaskResult 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /PSP-Inventory/formats/securityupdate.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | default 6 | 7 | PSP.Inventory.SecurityUpdate 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 15 | left 16 | 17 | 18 | 19 | 9 20 | left 21 | 22 | 23 | 24 | 12 25 | left 26 | 27 | 28 | 29 | 21 30 | left 31 | 32 | 33 | 34 | 35 | 36 | 37 | ComputerName 38 | 39 | 40 | Type 41 | 42 | 43 | KBFile 44 | 45 | 46 | InstallDate 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /PSP-Inventory/formats/sysinfo.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | default 6 | 7 | PSP.Inventory.SystemInfo 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 15 | left 16 | 17 | 18 | 19 | 20 20 | left 21 | 22 | 23 | 24 | 15 25 | left 26 | 27 | 28 | 29 | 16 30 | left 31 | 32 | 33 | 34 | 28 35 | left 36 | 37 | 38 | 39 | 24 40 | left 41 | 42 | 43 | 44 | 45 | 46 | 47 | ComputerName 48 | 49 | 50 | Model 51 | 52 | 53 | SerialNumber 54 | 55 | 56 | NumberofCores 57 | 58 | 59 | NumberOfLogicalProcessors 60 | 61 | 62 | TotalPhysicalMemoryGB 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /PSP-Inventory/formats/vminfo.format.ps1xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | default 6 | 7 | PSP.Inventory.VMInfo 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 15 | left 16 | 17 | 18 | 19 | 18 20 | left 21 | 22 | 23 | 24 | 18 25 | left 26 | 27 | 28 | 29 | 31 30 | left 31 | 32 | 33 | 34 | 21 35 | left 36 | 37 | 38 | 39 | 40 | 41 | 42 | ComputerName 43 | 44 | 45 | HVVMName 46 | 47 | 48 | HVHostName 49 | 50 | 51 | HVIntegrationServicesRunning 52 | 53 | 54 | VMWareToolsRunning 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /PSP-Inventory/private/Convert-ChassisType.ps1: -------------------------------------------------------------------------------- 1 | Function Convert-ChassisType 2 | { 3 | <# 4 | .SYNOPSIS 5 | Converts chassis types from hex to strings 6 | 7 | .DESCRIPTION 8 | Converts chassis types from hex to strings 9 | 10 | .PARAMETER ChassisType 11 | Provide hex representation of chassis type to convert to string value 12 | 13 | .EXAMPLE 14 | Convert-ChassisType -ChassisType 0x000A 15 | 16 | Description 17 | ----------- 18 | Converts the chassis value of 0x000A to the string value of 'Notebook' 19 | 20 | .NOTES 21 | Name: Convert-ChassisType.ps1 22 | Author: Robert Prüst 23 | Module: PSP-Inventory 24 | DateCreated: 20-02-2019 25 | DateModified: 27-02-2019 26 | Blog: https://powershellpr0mpt.com 27 | 28 | .LINK 29 | https://powershellpr0mpt.com 30 | #> 31 | 32 | [cmdletbinding()] 33 | param ( 34 | [int[]]$ChassisType 35 | ) 36 | $List = New-Object System.Collections.ArrayList 37 | Switch ($ChassisType) 38 | { 39 | 0x0001 {[void]$List.Add('Other')} 40 | 0x0002 {[void]$List.Add('Unknown')} 41 | 0x0003 {[void]$List.Add('Desktop')} 42 | 0x0004 {[void]$List.Add('Low Profile Desktop')} 43 | 0x0005 {[void]$List.Add('Pizza Box')} 44 | 0x0006 {[void]$List.Add('Mini Tower')} 45 | 0x0007 {[void]$List.Add('Tower')} 46 | 0x0008 {[void]$List.Add('Portable')} 47 | 0x0009 {[void]$List.Add('Laptop')} 48 | 0x000A {[void]$List.Add('Notebook')} 49 | 0x000B {[void]$List.Add('Hand Held')} 50 | 0x000C {[void]$List.Add('Docking Station')} 51 | 0x000D {[void]$List.Add('All in One')} 52 | 0x000E {[void]$List.Add('Sub Notebook')} 53 | 0x000F {[void]$List.Add('Space-Saving')} 54 | 0x0010 {[void]$List.Add('Lunch Box')} 55 | 0x0011 {[void]$List.Add('Main System Chassis')} 56 | 0x0012 {[void]$List.Add('Expansion Chassis')} 57 | 0x0013 {[void]$List.Add('Subchassis')} 58 | 0x0014 {[void]$List.Add('Bus Expansion Chassis')} 59 | 0x0015 {[void]$List.Add('Peripheral Chassis')} 60 | 0x0016 {[void]$List.Add('Storage Chassis')} 61 | 0x0017 {[void]$List.Add('Rack Mount Chassis')} 62 | 0x0018 {[void]$List.Add('Sealed-Case PC')} 63 | } 64 | $List -join ', ' 65 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/Convert-DomainRole.ps1: -------------------------------------------------------------------------------- 1 | function Convert-DomainRole 2 | { 3 | [cmdletbinding()] 4 | param( 5 | [int]$DomainRole 6 | ) 7 | switch ($DomainRole) 8 | { 9 | 0 { "Standalone Workstation" } 10 | 1 { "Member Workstation" } 11 | 2 { "Standalone Server" } 12 | 3 { "Member Server" } 13 | 4 { "Backup Domain Controller" } 14 | 5 { "Primary Domain Controller" } 15 | Default { "Member Server" } 16 | } 17 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/Convert-NetworkStatus.ps1: -------------------------------------------------------------------------------- 1 | function Convert-NetworkStatus 2 | { 3 | <# 4 | .SYNOPSIS 5 | Converts network status values from integers to strings 6 | 7 | .DESCRIPTION 8 | Converts network status values from integers to strings 9 | 10 | .PARAMETER NetworkStatus 11 | Provide integer representation of network status values to convert to string value 12 | 13 | .EXAMPLE 14 | Convert-NetworkStatus -NetworkStatus 0x000A 15 | 16 | Description 17 | ----------- 18 | Converts the network status value of 5 to the string value of 'Hardware disabled' 19 | 20 | .NOTES 21 | Name: Convert-NetworkStatus.ps1 22 | Author: Robert Prüst 23 | Module: PSP-Inventory 24 | DateCreated: 20-02-2019 25 | DateModified: 27-02-2019 26 | Blog: https://powershellpr0mpt.com 27 | 28 | .LINK 29 | https://powershellpr0mpt.com 30 | #> 31 | 32 | [cmdletbinding()] 33 | param( 34 | [int]$NetworkStatus 35 | ) 36 | switch ($NetworkStatus) 37 | { 38 | 0 { "Disconnected" } 39 | 1 { "Connecting" } 40 | 2 { "Connected" } 41 | 3 { "Disconnecting" } 42 | 4 { "Hardware not present" } 43 | 5 { "Hardware disabled" } 44 | 6 { "Hardware malfunction" } 45 | 7 { "Media disconnected" } 46 | 8 { "Authenticating" } 47 | 9 { "Authentication succeeded" } 48 | 10 { "Authentication failed" } 49 | 11 { "Invalid Address" } 50 | 12 { "Credentials Required" } 51 | Default { "Not connected" } 52 | } 53 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/Convert-UserFlag.ps1: -------------------------------------------------------------------------------- 1 | Function Convert-UserFlag 2 | { 3 | <# 4 | .SYNOPSIS 5 | Converts UserFlag enumerations to readable output 6 | 7 | .DESCRIPTION 8 | Converts UserFlag enumerations to readable output 9 | https://docs.microsoft.com/en-us/windows/desktop/api/iads/ne-iads-ads_user_flag 10 | 11 | .PARAMETER UserFlag 12 | Provide the UserFlag enum to convert to readable output 13 | 14 | .EXAMPLE 15 | Convert-UserFlag -NetworkStatus 0x000A 16 | 17 | Description 18 | ----------- 19 | Converts the UserFlag enumerations value of 65536 to the string value of 'DONT_EXPIRE_PASSWORD' 20 | 21 | .NOTES 22 | Name: Convert-UserFlag.ps1 23 | Author: Robert Prüst 24 | Module: PSP-Inventory 25 | DateCreated: 20-02-2019 26 | DateModified: 27-02-2019 27 | Blog: https://powershellpr0mpt.com 28 | 29 | .LINK 30 | https://powershellpr0mpt.com 31 | #> 32 | 33 | [cmdletbinding()] 34 | param ( 35 | $UserFlag 36 | ) 37 | $List = New-Object System.Collections.ArrayList 38 | Switch ($UserFlag) 39 | { 40 | ($UserFlag -BOR 0x0001) {[void]$List.Add('SCRIPT')} 41 | ($UserFlag -BOR 0x0002) {[void]$List.Add('ACCOUNTDISABLED')} 42 | ($UserFlag -BOR 0x0008) {[void]$List.Add('HOMEDIR_REQUIRED')} 43 | ($UserFlag -BOR 0x0010) {[void]$List.Add('LOCKOUT')} 44 | ($UserFlag -BOR 0x0020) {[void]$List.Add('PASSWD_NOTREQD')} 45 | ($UserFlag -BOR 0x0040) {[void]$List.Add('PASSWD_CANT_CHANGE')} 46 | ($UserFlag -BOR 0x0080) {[void]$List.Add('ENCRYPTED_TEXT_PWD_ALLOWED')} 47 | ($UserFlag -BOR 0x0100) {[void]$List.Add('TEMP_DUPLICATE_ACCOUNT')} 48 | ($UserFlag -BOR 0x0200) {[void]$List.Add('NORMAL_ACCOUNT')} 49 | ($UserFlag -BOR 0x0800) {[void]$List.Add('INTERDOMAIN_TRUST_ACCOUNT')} 50 | ($UserFlag -BOR 0x1000) {[void]$List.Add('WORKSTATION_TRUST_ACCOUNT')} 51 | ($UserFlag -BOR 0x2000) {[void]$List.Add('SERVER_TRUST_ACCOUNT')} 52 | ($UserFlag -BOR 0x10000) {[void]$List.Add('DONT_EXPIRE_PASSWORD')} 53 | ($UserFlag -BOR 0x20000) {[void]$List.Add('MNS_LOGON_ACCOUNT')} 54 | ($UserFlag -BOR 0x40000) {[void]$List.Add('SMARTCARD_REQUIRED')} 55 | ($UserFlag -BOR 0x80000) {[void]$List.Add('TRUSTED_FOR_DELEGATION')} 56 | ($UserFlag -BOR 0x100000) {[void]$List.Add('NOT_DELEGATED')} 57 | ($UserFlag -BOR 0x200000) {[void]$List.Add('USE_DES_KEY_ONLY')} 58 | ($UserFlag -BOR 0x400000) {[void]$List.Add('DONT_REQ_PREAUTH')} 59 | ($UserFlag -BOR 0x800000) {[void]$List.Add('PASSWORD_EXPIRED')} 60 | ($UserFlag -BOR 0x1000000) {[void]$List.Add('TRUSTED_TO_AUTH_FOR_DELEGATION')} 61 | ($UserFlag -BOR 0x04000000) {[void]$List.Add('PARTIAL_SECRETS_ACCOUNT')} 62 | } 63 | $List -join '; ' 64 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/ConvertTo-SID.ps1: -------------------------------------------------------------------------------- 1 | Function ConvertTo-SID 2 | { 3 | <# 4 | .SYNOPSIS 5 | Converts a binary SID object to SID 6 | 7 | .DESCRIPTION 8 | Converts a binary SID object to SID 9 | 10 | .PARAMETER BinarySID 11 | Provide the binary SID object to be converted to SID 12 | 13 | .EXAMPLE 14 | $User = ([ADSI]"WinNT://$env:COMPUTERNAME").Children | ? {$_.SchemaClassName -eq 'User'} | Select-Object -First 1 15 | ConvertTo-SID -BinarySID $User.objectSID[0] 16 | 17 | Description 18 | ----------- 19 | Converts the binary SID object value to the SID value of 'S-1-5-21-1229050671-3685773596-3126007646-504' 20 | 21 | .NOTES 22 | Name: ConvertTo-SID.ps1 23 | Author: Robert Prüst 24 | Module: PSP-Inventory 25 | DateCreated: 20-02-2019 26 | DateModified: 27-02-2019 27 | Blog: https://powershellpr0mpt.com 28 | 29 | .LINK 30 | https://powershellpr0mpt.com 31 | #> 32 | 33 | [cmdletbinding()] 34 | param( 35 | [byte[]]$BinarySID 36 | ) 37 | (New-Object System.Security.Principal.SecurityIdentifier($BinarySID, 0)).Value 38 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetCertInfo.ps1: -------------------------------------------------------------------------------- 1 | function _GetCertInfo { 2 | [cmdletbinding()] 3 | Param( 4 | [System.Management.Automation.Runspaces.PSSession]$PSSession, 5 | [string]$StoreName, 6 | [string]$StoreLocation 7 | ) 8 | Write-Verbose "[$($PSSession.ComputerName)] - Gathering Certificate information" 9 | $Certificates = Invoke-Command -Session $PSSession -ScriptBlock { 10 | Get-ChildItem "Cert:\$Using:StoreLocation\$Using:StoreName" 11 | } 12 | foreach ($Certificate in $Certificates) { 13 | [PSCustomObject]@{ 14 | PSTypeName = 'PSP.Inventory.Certificate' 15 | ComputerName = $PSSession.ComputerName.ToUpper() 16 | StoreName = $StoreName 17 | StoreLocation = $StoreLocation 18 | FriendlyName = $Certificate.FriendlyName 19 | Thumbprint = $Certificate.Thumbprint 20 | Issuer = $Certificate.Issuer 21 | NotBefore = $Certificate.NotBefore 22 | NotAfter = $Certificate.NotAfter 23 | Subject = $Certificate.Subject 24 | HasPrivateKey = $Certificate.HasPrivateKey 25 | InventoryDate = (Get-Date) 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetDiskInfo.ps1: -------------------------------------------------------------------------------- 1 | function _GetDiskInfo { 2 | [cmdletbinding()] 3 | Param( 4 | [Microsoft.Management.Infrastructure.CimSession]$Cimsession 5 | ) 6 | Write-Verbose "[$($CimSession.ComputerName)] - Gathering Disk information" 7 | $Volumes = Get-CimInstance -CimSession $CimSession -ClassName Win32_LogicalDisk -Filter "DriveType = 3" -ErrorAction Stop 8 | foreach ($Volume in $Volumes) { 9 | $Partition = Get-CimAssociatedInstance -CimSession $CimSession -InputObject $Volume -ResultClass Win32_DiskPartition 10 | $Disk = Get-CimAssociatedInstance -CimSession $CimSession -InputObject $Partition -ResultClassName Win32_DiskDrive 11 | 12 | [PSCustomObject]@{ 13 | PSTypeName = 'PSP.Inventory.Disk' 14 | ComputerName = $CimSession.ComputerName 15 | DriveLetter = $Volume.Caption 16 | Label = $Volume.VolumeName 17 | FileSystem = $Volume.FileSystem 18 | ClusterSize = $Partition.BlockSize 19 | VolumeTotalSizeGB = [math]::round(($Volume.Size / 1GB), 2) 20 | VolumeFreeSizeGB = [math]::round(($Volume.FreeSpace / 1GB), 2) 21 | VolumeUsedSizeGB = [math]::round((($Volume.Size - $Volume.FreeSpace) / 1GB), 2) 22 | DiskFriendlyName = $Disk.Caption 23 | DiskTotalSizeGB = [math]::round(($Disk.Size / 1GB), 2) 24 | DiskSerialNumber = $Disk.SerialNumber 25 | DiskFirmware = $Disk.FirmwareRevision 26 | DiskModel = $Disk.Model 27 | DiskInterface = $Disk.InterfaceType 28 | DiskNumber = $Disk.Index 29 | PartitionNumber = $Partition.Index 30 | IsPrimaryPartition = $Partition.PrimaryPartition 31 | IsBootPartition = $Partition.BootPartition 32 | InventoryDate = (Get-Date) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetLocalGroup.ps1: -------------------------------------------------------------------------------- 1 | function _GetLocalGroup { 2 | [cmdletbinding()] 3 | Param( 4 | [System.Management.Automation.Runspaces.PSSession]$PSSession 5 | ) 6 | Invoke-Command -Session $PSSession -ScriptBlock { 7 | $Computer = $env:COMPUTERNAME.ToUpper() 8 | Write-Verbose "[$Computer] - Gathering Local Group information" 9 | Function ConvertTo-SID{ 10 | [cmdletbinding()] 11 | param( 12 | [byte[]]$BinarySID 13 | ) 14 | (New-Object System.Security.Principal.SecurityIdentifier($BinarySID, 0)).Value 15 | } 16 | Function _GetLocalGroupMember { 17 | [cmdletbinding()] 18 | param ( 19 | $Group 20 | ) 21 | $Group.Invoke('Members') | ForEach-Object { 22 | $_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null) 23 | } 24 | } 25 | try { 26 | $DomainRole = (Get-WmiObject -Class Win32_ComputerSystem -Property DomainRole -ErrorAction Stop).DomainRole 27 | if (!($DomainRole -match "4|5")){ 28 | $GroupInfo = ([ADSI]"WinNT://$Computer").Children | Where-Object {$_.SchemaClassName -eq 'Group'} 29 | foreach ($Group in $GroupInfo) { 30 | [PSCustomObject]@{ 31 | PSTypeName = 'PSP.Inventory.LocalGroup' 32 | ComputerName = $Computer 33 | GroupName = $Group.Name[0] 34 | Members = ((_GetLocalGroupMember -Group $Group) -join '; ') 35 | GroupType = $GroupType[[int]$Group.GroupType[0]] 36 | SID = (ConvertTo-SID -BinarySID $Group.ObjectSid[0]) 37 | InventoryDate = (Get-Date) 38 | } 39 | } 40 | }else { 41 | Write-Warning "[$Computer] - is a Domain Controller, no local groups available" 42 | } 43 | }catch{ 44 | Write-Warning "[$Computer] - Unable to check domain role, skipping information collection." 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetLocalGroupMember.ps1: -------------------------------------------------------------------------------- 1 | Function _GetLocalGroupMember { 2 | <# 3 | .SYNOPSIS 4 | Gets the members of a local group 5 | 6 | .DESCRIPTION 7 | Gets the members of a local group 8 | 9 | .PARAMETER Group 10 | Provide the local group name to query for its members 11 | 12 | .EXAMPLE 13 | _GetLocalGroupMember -Group Administrators 14 | 15 | Description 16 | ----------- 17 | Gets all the members of the local group 'Administrators' 18 | 19 | .NOTES 20 | Name: _GetLocalGroupMember.ps1 21 | Author: Robert Prüst 22 | Module: PSP-Inventory 23 | DateCreated: 20-02-2019 24 | DateModified: 07-03-2019 25 | Blog: https://powershellpr0mpt.com 26 | 27 | .LINK 28 | https://powershellpr0mpt.com 29 | #> 30 | 31 | [cmdletbinding()] 32 | param ( 33 | $Group 34 | ) 35 | $Group.Invoke('Members') | ForEach-Object { 36 | $_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null) 37 | } 38 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetLocalUser.ps1: -------------------------------------------------------------------------------- 1 | function _GetLocalUser { 2 | [cmdletbinding()] 3 | Param( 4 | [System.Management.Automation.Runspaces.PSSession]$PSSession 5 | ) 6 | Invoke-Command -Session $PSSession -ScriptBlock { 7 | $Computer = $env:COMPUTERNAME.ToUpper() 8 | Write-Verbose "[$Computer] - Gathering Local User information" 9 | Function ConvertTo-SID{ 10 | [cmdletbinding()] 11 | param( 12 | [byte[]]$BinarySID 13 | ) 14 | (New-Object System.Security.Principal.SecurityIdentifier($BinarySID, 0)).Value 15 | } 16 | Function Convert-UserFlag { 17 | [cmdletbinding()] 18 | param ( 19 | $UserFlag 20 | ) 21 | $List = New-Object System.Collections.ArrayList 22 | Switch ($UserFlag) 23 | { 24 | ($UserFlag -BOR 0x0001) {[void]$List.Add('SCRIPT')} 25 | ($UserFlag -BOR 0x0002) {[void]$List.Add('ACCOUNTDISABLED')} 26 | ($UserFlag -BOR 0x0008) {[void]$List.Add('HOMEDIR_REQUIRED')} 27 | ($UserFlag -BOR 0x0010) {[void]$List.Add('LOCKOUT')} 28 | ($UserFlag -BOR 0x0020) {[void]$List.Add('PASSWD_NOTREQD')} 29 | ($UserFlag -BOR 0x0040) {[void]$List.Add('PASSWD_CANT_CHANGE')} 30 | ($UserFlag -BOR 0x0080) {[void]$List.Add('ENCRYPTED_TEXT_PWD_ALLOWED')} 31 | ($UserFlag -BOR 0x0100) {[void]$List.Add('TEMP_DUPLICATE_ACCOUNT')} 32 | ($UserFlag -BOR 0x0200) {[void]$List.Add('NORMAL_ACCOUNT')} 33 | ($UserFlag -BOR 0x0800) {[void]$List.Add('INTERDOMAIN_TRUST_ACCOUNT')} 34 | ($UserFlag -BOR 0x1000) {[void]$List.Add('WORKSTATION_TRUST_ACCOUNT')} 35 | ($UserFlag -BOR 0x2000) {[void]$List.Add('SERVER_TRUST_ACCOUNT')} 36 | ($UserFlag -BOR 0x10000) {[void]$List.Add('DONT_EXPIRE_PASSWORD')} 37 | ($UserFlag -BOR 0x20000) {[void]$List.Add('MNS_LOGON_ACCOUNT')} 38 | ($UserFlag -BOR 0x40000) {[void]$List.Add('SMARTCARD_REQUIRED')} 39 | ($UserFlag -BOR 0x80000) {[void]$List.Add('TRUSTED_FOR_DELEGATION')} 40 | ($UserFlag -BOR 0x100000) {[void]$List.Add('NOT_DELEGATED')} 41 | ($UserFlag -BOR 0x200000) {[void]$List.Add('USE_DES_KEY_ONLY')} 42 | ($UserFlag -BOR 0x400000) {[void]$List.Add('DONT_REQ_PREAUTH')} 43 | ($UserFlag -BOR 0x800000) {[void]$List.Add('PASSWORD_EXPIRED')} 44 | ($UserFlag -BOR 0x1000000) {[void]$List.Add('TRUSTED_TO_AUTH_FOR_DELEGATION')} 45 | ($UserFlag -BOR 0x04000000) {[void]$List.Add('PARTIAL_SECRETS_ACCOUNT')} 46 | } 47 | $List -join '; ' 48 | } 49 | try { 50 | $DomainRole = (Get-WmiObject -Class Win32_ComputerSystem -Property DomainRole -ErrorAction Stop).DomainRole 51 | if (!($DomainRole -match "4|5")){ 52 | $UserInfo = ([ADSI]"WinNT://$Computer").Children | Where-Object {$_.SchemaClassName -eq 'User'} 53 | foreach ($User in $UserInfo) { 54 | [PSCustomObject]@{ 55 | PSTypeName = 'PSP.Inventory.LocalUser' 56 | ComputerName = $Computer 57 | UserName = $User.Name[0] 58 | Description = $User.Description[0] 59 | LastLogin = if ($User.LastLogin[0] -is [datetime]) {$User.LastLogin[0]}else {$null} 60 | SID = (ConvertTo-SID -BinarySID $User.ObjectSid[0]) 61 | UserFlags = (Convert-UserFlag -UserFlag $User.UserFlags[0]) 62 | InventoryDate = (Get-Date) 63 | } 64 | } 65 | }else { 66 | Write-Warning "[$Computer] - is a Domain Controller, no local users available" 67 | } 68 | }catch{ 69 | Write-Warning "[$Computer] - Unable to check domain role, skipping information collection." 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetNicInfo.ps1: -------------------------------------------------------------------------------- 1 | function _GetNicInfo { 2 | [cmdletbinding()] 3 | Param( 4 | [Microsoft.Management.Infrastructure.CimSession]$Cimsession, 5 | [Switch]$Drivers 6 | ) 7 | Write-Verbose "[$($CimSession.ComputerName)] - Gathering Netwok Interface information" 8 | $Adapters = Get-CimInstance -CimSession $CimSession -ClassName Win32_NetworkAdapter -Filter "Availability =3" -Property Name, NetConnectionID, DeviceId, PhysicalAdapter, NetConnectionStatus, Speed, MacAddress, AdapterTypeId -ErrorAction Stop | Where-Object {$_.AdapterTypeId -match '0|9'} 9 | if ($Drivers) { 10 | $SignedDrivers = Get-CimInstance -CimSession $CimSession -ClassName Win32_PnPSignedDriverCIMDataFile 11 | } 12 | foreach ($Adapter in $Adapters) { 13 | if ($Adapter.Speed) { 14 | $LinkSpeed = $Adapter.Speed / 1000000 15 | } 16 | else { 17 | $LinkSpeed = (Get-CimInstance -CimSession $CimSession -Namespace "root/wmi" -Query "SELECT * FROM MSNdis_LinkSpeed" | Where-Object {$_.InstanceName -eq $Adapter.Name}).NdisLinkSpeed / 1000 18 | } 19 | if ($Drivers) { 20 | $DriverInfo = Get-CimInstance -CimSession $CimSession -ClassName Win32_PnPSignedDriver -Filter "Description='$($Adapter.Name)'" -Property InfName, DriverVersion, DriverDate, Description, DriverProviderName, Manufacturer, DeviceId 21 | } 22 | $Config = Get-CimInstance -CimSession $CimSession -ClassName Win32_NetworkAdapterConfiguration -Filter "Index = '$($Adapter.DeviceId)'" -Property IPAddress, DHCPEnabled, DHCPServer, DNSServerSearchOrder, DefaultIPGateway, IPSubnet 23 | 24 | [PSCustomObject]@{ 25 | PSTypeName = 'PSP.Inventory.NIC' 26 | ComputerName = $Cimsession.ComputerName 27 | Alias = $Adapter.NetConnectionID 28 | Index = $Adapter.DeviceId 29 | PhysicalAdapter = $Adapter.PhysicalAdapter 30 | IPAddress = $Config.IPAddress 31 | Status = (Convert-NetworkStatus -NetworkStatus $Adapter.NetConnectionStatus) 32 | MacAddress = $Adapter.MacAddress 33 | DHCPEnabled = $Config.DHCPEnabled 34 | DHCPServer = $Config.DHCPServer 35 | DNSServers = $Config.DNSServerSearchOrder 36 | Gateway = $Config.DefaultIPGateway 37 | Subnet = $Config.IPSubnet 38 | LinkspeedMB = $LinkSpeed 39 | DriverInf = if ($Drivers) {$DriverInfo.InfName}else {''} 40 | DriverFileName = if ($Drivers) {$SignedDrivers.Where{$_.Antecedent.DeviceId -eq $DriverInfo.DeviceId}[0].Dependent.Name}else {''} 41 | DriverVersion = if ($Drivers) {$DriverInfo.DriverVersion}else {''} 42 | DriverDate = if ($Drivers) {$DriverInfo.DriverDate}else {''} 43 | DriverDescription = if ($Drivers) {$DriverInfo.Description}else {''} 44 | DriverProvider = if ($Drivers) {$DriverInfo.DriverProviderName}else {''} 45 | NicManufacturer = if ($Drivers) {$DriverInfo.Manufacturer}else {''} 46 | InventoryDate = (Get-Date) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetOSInfo.ps1: -------------------------------------------------------------------------------- 1 | function _GetOSInfo { 2 | [cmdletbinding()] 3 | Param( 4 | [Microsoft.Management.Infrastructure.CimSession]$Cimsession 5 | ) 6 | Write-Verbose "[$($CimSession.ComputerName)] - Gathering OS information" 7 | $TimeZone = Get-CimInstance -CimSession $CimSession -ClassName Win32_TimeZone -Property Caption -ErrorAction Stop 8 | $OS = Get-CimInstance -CimSession $CimSession -ClassName Win32_OperatingSystem -Property Caption, Version, ServicePackMajorVersion, ServicePackMinorVersion, LastBootUpTime, OSArchitecture, InstallDate 9 | $ProductKey = (Get-CimInstance -CimSession $CimSession -Query 'SELECT OA3xOriginalProductKey FROM SoftwareLicensingService' -ErrorAction SilentlyContinue).OA3xOriginalProductKey 10 | $PageFile = Get-CimInstance -CimSession $CimSession -ClassName Win32_PageFile -Property Name, FileSize 11 | [PSCustomObject]@{ 12 | PSTypename = 'PSP.Inventory.OperatingSystemInfo' 13 | ComputerName = $Cimsession.ComputerName 14 | Caption = $OS.Caption 15 | Version = $OS.Version 16 | ServicePack = ("{0}.{1}" -f $OS.ServicePackMajorVersion, $OS.ServicePackMinorVersion) 17 | ProductKey = $ProductKey 18 | LastReboot = $OS.LastBootUpTime 19 | InstallDate = $OS.InstallDate 20 | OSArchitecture = $OS.OSArchitecture 21 | TimeZone = $TimeZone.Caption 22 | PageFile = if ($PageFile) {foreach ($File in $PageFile) {$File.Name}}else {$null} 23 | PageFileSizeGB = if ($PageFile) {foreach ($File in $PageFile) {([math]::round(($File.FileSize / 1GB), 0))}} else {$null} 24 | InventoryDate = (Get-Date) 25 | } 26 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetRoleInfo.ps1: -------------------------------------------------------------------------------- 1 | function _GetRoleInfo { 2 | [cmdletbinding()] 3 | Param( 4 | [Microsoft.Management.Infrastructure.CimSession]$Cimsession 5 | ) 6 | Write-Verbose "[$($CimSession.ComputerName)] - Gathering Server Role information" 7 | #Check if Workstation - https://docs.microsoft.com/en-us/windows/desktop/CIMWin32Prov/win32-operatingsystem#properties 8 | $ProductType = (Get-CimInstance -CimSession $CimSession -ClassName Win32_OperatingSystem -Property ProductType).ProductType 9 | if (!($ProductType -eq 1)){ 10 | Get-CimInstance -CimSession $CimSession -ClassName Win32_ServerFeature -Property Id, Name -ErrorAction Stop | ForEach-Object { 11 | [PSCustomObject]@{ 12 | PSTypeName = 'PSP.Inventory.ServerRole' 13 | ComputerName = $CimSession.ComputerName 14 | RoleId = $_.Id 15 | Name = $_.Name 16 | InventoryDate = (Get-Date) 17 | } 18 | } 19 | }else{ 20 | Write-Warning "[$($CimSession.ComputerName)] - is a workstation, no roles available" 21 | } 22 | } -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetSoftwareInfo.ps1: -------------------------------------------------------------------------------- 1 | function _GetSoftwareInfo { 2 | [cmdletbinding()] 3 | Param( 4 | [System.Management.Automation.Runspaces.PSSession]$PSSession 5 | ) 6 | Write-Verbose "[$($PSSession.ComputerName)] - Gathering Software information" 7 | $Programs = Invoke-Command -Session $PSSession -ScriptBlock { 8 | $Keys = @('HKLM:\SOFTWARE\Microsoft\Windows\Currentversion\Uninstall\*', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\Currentversion\Uninstall\*') 9 | Get-ItemProperty -Path $Keys -ErrorAction SilentlyContinue 10 | } 11 | foreach ($Program in $Programs) { 12 | if ($Program.DisplayName -AND $Program.DisplayName -notmatch '^Update for|rollup|^Security Update|^Service Pack|^HotFix') { 13 | [PSCustomObject]@{ 14 | PSTypeName = 'PSP.Inventory.Software' 15 | ComputerName = $PSSession.ComputerName 16 | DisplayName = $Program.DisplayName 17 | Version = $Program.DisplayVersion 18 | InstallDate = if ($Program.InstallDate) {try {[datetime]::ParseExact($($Program.InstallDate), 'yyyyMMdd', [System.Globalization.CultureInfo]::InvariantCulture)}catch{$null}} else {$null} 19 | Publisher = $Program.Publisher 20 | UninstallString = $Program.UninstallString 21 | InstallLocation = $Program.InstallLocation 22 | InstallSource = $Program.InstallSource 23 | HelpLink = $Program.HelpLink 24 | EstimatedSize = [math]::Round(($Program.EstimatedSize * 1024) / 1MB, 2) 25 | InventoryDate = (Get-Date) 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetSysInfo.ps1: -------------------------------------------------------------------------------- 1 | function _GetSysInfo { 2 | [cmdletbinding()] 3 | Param( 4 | [Microsoft.Management.Infrastructure.CimSession]$Cimsession 5 | ) 6 | Write-Verbose "[$($CimSession.ComputerName)] - Gathering System information" 7 | $CS = Get-CimInstance -CimSession $CimSession -ClassName Win32_ComputerSystem -Property Manufacturer, Model, SystemType, NumberOfProcessors, NumberOfLogicalProcessors, TotalPhysicalMemory, Domain, DomainRole -ErrorAction Stop 8 | $Enclosure = Get-CimInstance -CimSession $CimSession -ClassName Win32_SystemEnclosure -Property SerialNumber, ChassisTypes, Description 9 | $BIOS = Get-CimInstance -CimSession $CimSession -ClassName Win32_Bios -Property Name, Manufacturer, SerialNumber, SMBIOSBIOSVersion 10 | [PSCustomObject]@{ 11 | PSTypeName = 'PSP.Inventory.SystemInfo' 12 | ComputerName = $Cimsession.ComputerName 13 | Domain = $CS.Domain 14 | DomainRole = (Convert-DomainRole $CS.DomainRole) 15 | Manufacturer = $CS.Manufacturer 16 | Model = $CS.Model 17 | SystemType = $CS.SystemType 18 | State = if ($CS.Manufacturer -match "Hyper|Citrix|VMWare|virtual|Microsoft") {'Virtual'}else {'Physical'} 19 | SerialNumber = $Enclosure.SerialNumber 20 | ChassisType = (Convert-ChassisType $Enclosure.ChassisTypes) 21 | Description = $Enclosure.Description 22 | NumberofCores = $CS.NumberOfProcessors 23 | NumberOfLogicalProcessors = $CS.NumberOfLogicalProcessors 24 | TotalPhysicalMemoryGB = ([math]::round(($CS.TotalPhysicalMemory / 1GB), 0)) 25 | BIOSManufacturer = $BIOS.Manufacturer 26 | BIOSName = $BIOS.Name 27 | BIOSSerialNumber = $BIOS.SerialNumber 28 | BIOSVersion = $BIOS.SMBIOSBIOSVersion 29 | InventoryDate = (Get-Date) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetUpdateInfo.ps1: -------------------------------------------------------------------------------- 1 | function _GetUpdateInfo { 2 | [cmdletbinding()] 3 | Param( 4 | [Microsoft.Management.Infrastructure.CimSession]$Cimsession 5 | ) 6 | Write-Verbose "[$($CimSession.ComputerName)] - Gathering Security Update information" 7 | try { 8 | $Updates = Get-CimInstance -CimSession $CimSession -ClassName Win32_QuickFixEngineering -ErrorAction Stop 9 | $Updates | ForEach-Object { 10 | [PSCustomObject]@{ 11 | PSTypeName = 'PSP.Inventory.SecurityUpdate' 12 | ComputerName = $Cimsession.ComputerName 13 | KBFile = $_.HotFixID 14 | Type = $_.Description 15 | KBLink = $_.Caption 16 | InstalledBy = $_.InstalledBy 17 | InstallDate = $_.InstalledOn 18 | InventoryDate = (Get-Date) 19 | } 20 | } 21 | } 22 | catch [Microsoft.Management.Infrastructure.CimException] { 23 | Write-Warning "[$($CimSession.ComputerName)] - Unable to access data over WinRM, trying DCOM instead" 24 | $CimOptions = New-CimSessionOption -Protocol DCOM 25 | 26 | $CimProperties = @{ 27 | ErrorAction = 'Stop' 28 | Computername = $Cimsession.ComputerName 29 | SessionOption = $CimOptions 30 | } 31 | try { 32 | $NewCimSession = New-CimSession @CimProperties 33 | } 34 | catch { 35 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 36 | } 37 | Finally { 38 | $CimProperties.Remove('SessionOption') | Out-Null 39 | } 40 | try { 41 | $Updates = Get-CimInstance -CimSession $NewCimSession -ClassName Win32_QuickFixEngineering -ErrorAction Stop 42 | $Updates | ForEach-Object { 43 | [PSCustomObject]@{ 44 | PSTypeName = 'PSP.Inventory.SecurityUpdate' 45 | ComputerName = $NewCimsession.ComputerName 46 | KBFile = $_.HotFixID 47 | Type = $_.Description 48 | KBLink = $_.Caption 49 | InstalledBy = $_.InstalledBy 50 | InstallDate = $_.InstalledOn 51 | InventoryDate = (Get-Date) 52 | } 53 | } 54 | } catch { 55 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /PSP-Inventory/private/_GetVMInfo.ps1: -------------------------------------------------------------------------------- 1 | function _GetVMInfo { 2 | [cmdletbinding()] 3 | Param( 4 | [System.Management.Automation.Runspaces.PSSession]$PSSession 5 | ) 6 | Write-Verbose "[$($PSSession.ComputerName)] - Gathering VM information" 7 | $VMInfo = Invoke-Command -Session $PSSession -ScriptBlock { 8 | $HVService = Get-Service -DisplayName '*Hyper-V*' | Where-Object {$_.Status -eq 'Running'} 9 | $HVProperties = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters' -Name VirtualMachineName, PhysicalHostNameFullyQualified -ErrorAction SilentlyContinue 10 | $VMService = Get-Service -Name VMTools -ErrorAction SilentlyContinue 11 | [PSCustomObject]@{ 12 | HVIntegrationServicesRunning = if ($HVService) {$true}else {$false} 13 | HVHostName = if ($HVProperties) {$HVProperties.PhysicalHostNameFullyQualified}else {$null} 14 | HVVMName = if ($HVProperties) {$HVProperties.VirtualMachineName}else {$null} 15 | VMWareToolsRunning = if ($VMService) {$true}else {$false} 16 | } 17 | } 18 | [PSCustomObject]@{ 19 | PSTypeName = 'PSP.Inventory.VMInfo' 20 | ComputerName = $PSSession.ComputerName 21 | HVIntegrationServicesRunning = $VMInfo.HVIntegrationServicesRunning 22 | HVHostName = $VMInfo.HVHostName 23 | HVVMName = $VMInfo.HVVMName 24 | VMWareToolsRunning = $VMInfo.VMWareToolsRunning 25 | InventoryDate = (Get-Date) 26 | } 27 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspCertificate.ps1: -------------------------------------------------------------------------------- 1 | Function Get-PspCertificate { 2 | <# 3 | .SYNOPSIS 4 | Get certification information for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get certification information for local or remote machines. 8 | Allows you to specify exactly which store you want to query. 9 | 10 | .PARAMETER ComputerName 11 | Provide the computername(s) to query. 12 | Using this parameter will create a temporary PSSession to obtain the information if available. 13 | If PowerShell remoting is not available, it will try and obtain the information through .NET. 14 | Default value is the local machine. 15 | 16 | .PARAMETER Credential 17 | Provide the credentials for the PowerShell remoting session to be created if current credentials are not sufficient. 18 | 19 | .PARAMETER PSSession 20 | Provide the PowerShell remoting session object to query if this is already available. 21 | Once the information has been gathered, the PowerShell session will remain available for further use. 22 | 23 | .PARAMETER StoreName 24 | Provide the StoreName to query. 25 | Default value is the 'My' name. 26 | 27 | .PARAMETER StoreLocation 28 | Provide the Certification store to query. 29 | Default value is the 'LocalMachine' store. 30 | 31 | .EXAMPLE 32 | PS C:\> Get-PspCertificate -ComputerName 'CONTOSO-SRV01' 33 | 34 | ComputerName NotAfter NotBefore Subject Thumbprint 35 | ------------ -------- --------- ------- ---------- 36 | CONTOSO-SRV01 9-9-2038 11:31:44 14-9-2018 11:31:44 CN=127.0.0.1 BA03E7647E61F2562A... 37 | CONTOSO-SRV01 23-11-2038 15:49:59 28-11-2018 15:49:59 CN=127.0.0.1 B9EDE957C09C462C68... 38 | CONTOSO-SRV01 12-3-2019 22:46:38 11-3-2019 22:41:38 CN=1d55f591-ad2c-43dd-abef-ff7e3e6a6f51, DC=dbddf572-f118-4b32-8139-dc6cd6bae4f8 69CD7B0FB0D244E4FA... 39 | CONTOSO-SRV01 3-12-2028 14:02:53 3-12-2018 13:32:53 CN=1d55f591-ad3c-43dd-abef-ff7e3e6a6f51 28165F4FDE3E0FAA24... 40 | CONTOSO-SRV01 3-12-2019 14:02:58 3-12-2018 13:52:58 CN=a8b24bcf-6f4c-4b8c-907e-37acb9b15d3b 0F674857164B0D4197... 41 | 42 | Gets the certification information for CONTOSO-SRV01 using the 'My' storename and 'LocalMachine' storelocation, displaying the default properties. 43 | 44 | .NOTES 45 | Name: Get-PspCertificate.ps1 46 | Author: Robert Prüst 47 | Module: PSP-Inventory 48 | DateCreated: 22-02-2019 49 | DateModified: 11-03-2019 50 | Blog: https://powershellpr0mpt.com 51 | 52 | .LINK 53 | https://powershellpr0mpt.com 54 | #> 55 | 56 | [OutputType('PSP.Inventory.Certificate')] 57 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 58 | param( 59 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 60 | [ValidateNotNullorEmpty()] 61 | [Alias('CN')] 62 | [String[]]$ComputerName = $env:COMPUTERNAME, 63 | [Parameter(ParameterSetName = 'Computer')] 64 | [PSCredential]$Credential, 65 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 66 | [Alias('Session')] 67 | [System.Management.Automation.Runspaces.PSSession[]]$PSSession, 68 | [Parameter(Position = 1)] 69 | [System.Security.Cryptography.X509Certificates.StoreName]$StoreName = 'My', 70 | [Parameter(Position = 2)] 71 | [System.Security.Cryptography.X509Certificates.StoreLocation]$StoreLocation = 'LocalMachine' 72 | ) 73 | process { 74 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 75 | foreach ($Computer in $ComputerName) { 76 | $Computer = $Computer.toUpper() 77 | try { 78 | Write-Verbose ("Connecting to {0}\{1}" -f "\\$($Computer)\$($StoreName)", $StoreLocation) 79 | $CertStore = New-Object System.Security.Cryptography.X509Certificates.X509Store -ArgumentList "\\$($Computer)\$($StoreName)", $StoreLocation 80 | $CertStore.Open('ReadOnly') 81 | $Certificates = $CertStore.Certificates 82 | foreach ($Certificate in $Certificates) { 83 | [PSCustomObject]@{ 84 | PSTypeName = 'PSP.Inventory.Certificate' 85 | ComputerName = $Computer 86 | StoreName = $StoreName 87 | StoreLocation = $StoreLocation 88 | FriendlyName = $Certificate.FriendlyName 89 | Thumbprint = $Certificate.Thumbprint 90 | Issuer = $Certificate.Issuer 91 | NotBefore = $Certificate.NotBefore 92 | NotAfter = $Certificate.NotAfter 93 | Subject = $Certificate.Subject 94 | HasPrivateKey = $Certificate.HasPrivateKey 95 | Certificate = $Certificate 96 | InventoryDate = (Get-Date) 97 | } 98 | } 99 | } 100 | catch { 101 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 102 | } 103 | } 104 | } 105 | foreach ($Session in $PSSession) { 106 | _GetCertInfo -PSSession $Session -StoreName $StoreName.ToString() -StoreLocation $StoreLocation.ToString() 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspDiskInfo.ps1: -------------------------------------------------------------------------------- 1 | function Get-PspDiskInfo { 2 | <# 3 | .SYNOPSIS 4 | Get Disk information for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get Disk information for local or remote machines. 8 | Will query Disks, partitions and volumes to obtain as much information as possible. 9 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 10 | If there's already a CIM session available, this can also be used to obtain the data. 11 | 12 | .PARAMETER ComputerName 13 | Provide the computername(s) to query. 14 | This will create a new CIM session which will be removed once the information has been gathered. 15 | Default value is the local machine. 16 | 17 | .PARAMETER Credential 18 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 19 | 20 | .PARAMETER CimSession 21 | Provide the CIM session object to query if this is already available. 22 | Once the information has been gathered, the CIM session will remain available for further use. 23 | 24 | .EXAMPLE 25 | PS C:\> Get-PspDiskInfo -ComputerName 'CONTOSO-SRV01','CONTOSO-WEB01' 26 | 27 | ComputerName DriveLetter FileSystem TotalSizeGB FreeSizeGB UsedSizeGB 28 | ------------ ----------- ---------- ----------- ---------- ---------- 29 | CONTOSO-SRV01 C: NTFS 50 38.81 11.19 30 | CONTOSO-WEB01 C: NTFS 49.36 41.81 7.55 31 | 32 | Gets the disk information for CONTOSO-SRV01 and CONTOSO-WEB01 by creating a temporary CIM session, displaying the default properties. 33 | 34 | .EXAMPLE 35 | PS C:\> $CimSession = New-CimSession -ComputerName 'CONTOSO-SRV02' 36 | PS C:\> Get-PspDiskInfo -CimSession $CimSession 37 | 38 | ComputerName DriveLetter FileSystem TotalSizeGB FreeSizeGB UsedSizeGB 39 | ------------ ----------- ---------- ----------- ---------- ---------- 40 | CONTOSO-SRV02 C: NTFS 50 38.81 11.19 41 | 42 | Creates a CIM session for CONTOSO-SRV02 and uses this session to get the Disk information from this machine. 43 | The session can then be re-used for other cmdlets in order to get more information. 44 | Re-using the session provides performance benefits. 45 | 46 | .NOTES 47 | Name: Get-PspDiskInfo.ps1 48 | Author: Robert Prüst 49 | Module: PSP-Inventory 50 | DateCreated: 22-12-2018 51 | DateModified: 11-03-2019 52 | Blog: https://powershellpr0mpt.com 53 | 54 | .LINK 55 | https://powershellpr0mpt.com 56 | #> 57 | 58 | [OutputType('PSP.Inventory.Disk')] 59 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 60 | param( 61 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 62 | [ValidateNotNullorEmpty()] 63 | [Alias('CN')] 64 | [String[]]$ComputerName = $env:COMPUTERNAME, 65 | [Parameter(ParameterSetName = 'Computer')] 66 | [PSCredential]$Credential, 67 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 68 | [Alias('Session')] 69 | [Microsoft.Management.Infrastructure.CimSession[]]$CimSession 70 | ) 71 | process { 72 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 73 | $CimSession = @() 74 | $CimProperties = @{ 75 | ErrorAction = 'Stop' 76 | Computername = '' 77 | } 78 | if ($credential.Username) { 79 | $CimProperties.Add('Credential', $Credential) 80 | } 81 | foreach ($Computer in $ComputerName) { 82 | $Computer = $Computer.toUpper() 83 | ` $CimProperties.ComputerName = $Computer 84 | Try { 85 | $CimSession += New-CimSession @CimProperties 86 | } 87 | catch [Microsoft.Management.Infrastructure.CimException] { 88 | Write-Warning "[$Computer] - does not have CIM access, reverting to DCOM instead" 89 | $CimOptions = New-CimSessionOption -Protocol DCOM 90 | $CimProperties.Add('SessionOption', $CimOptions) | Out-Null 91 | try { 92 | $CimSession += New-CimSession @CimProperties 93 | } 94 | catch { 95 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 96 | } 97 | Finally { 98 | $CimProperties.Remove('SessionOption') | Out-Null 99 | } 100 | } 101 | Catch { 102 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 103 | } 104 | } 105 | } 106 | foreach ($Session in $CimSession) { 107 | _GetDiskInfo -Cimsession $Session 108 | } 109 | } 110 | End { 111 | if ($PSCmdlet.ParameterSetName -eq 'Computer' -AND $CimSession.count -gt 0) { 112 | Remove-Cimsession $CimSession 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspLocalGroup.ps1: -------------------------------------------------------------------------------- 1 | Function Get-PspLocalGroup { 2 | <# 3 | .SYNOPSIS 4 | Get all local groups for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get all local groups for local or remote machines. 8 | Provides extra information such as members. 9 | 10 | .PARAMETER ComputerName 11 | Provide the computername(s) to query. 12 | Using this parameter will create a temporary PSSession to obtain the information if available. 13 | If PowerShell remoting is not available, it will try and obtain the information through ADSI. 14 | Default value is the local machine. 15 | 16 | .PARAMETER Credential 17 | Provide the credentials for the PowerShell remoting session to be created if current credentials are not sufficient. 18 | 19 | .PARAMETER PSSession 20 | Provide the PowerShell remoting session object to query if this is already available. 21 | Once the information has been gathered, the PowerShell session will remain available for further use. 22 | 23 | .EXAMPLE 24 | PS C:\> Get-PspLocalGroup -ComputerName CONTOSO-HV01 25 | 26 | ComputerName GroupName GroupType 27 | ------------ --------- --------- 28 | CONTOSO-HV01 Access Control Assistance Operators Local Group 29 | CONTOSO-HV01 Administrators Local Group 30 | CONTOSO-HV01 Backup Operators Local Group 31 | CONTOSO-HV01 Certificate Service DCOM Access Local Group 32 | CONTOSO-HV01 Cryptographic Operators Local Group 33 | CONTOSO-HV01 Distributed COM Users Local Group 34 | CONTOSO-HV01 Event Log Readers Local Group 35 | CONTOSO-HV01 Guests Local Group 36 | CONTOSO-HV01 Hyper-V Administrators Local Group 37 | CONTOSO-HV01 IIS_IUSRS Local Group 38 | CONTOSO-HV01 Network Configuration Operators Local Group 39 | CONTOSO-HV01 Performance Log Users Local Group 40 | CONTOSO-HV01 Performance Monitor Users Local Group 41 | CONTOSO-HV01 Power Users Local Group 42 | CONTOSO-HV01 Print Operators Local Group 43 | CONTOSO-HV01 RDS Endpoint Servers Local Group 44 | CONTOSO-HV01 RDS Management Servers Local Group 45 | CONTOSO-HV01 RDS Remote Access Servers Local Group 46 | CONTOSO-HV01 Remote Desktop Users Local Group 47 | CONTOSO-HV01 Remote Management Users Local Group 48 | CONTOSO-HV01 Replicator Local Group 49 | CONTOSO-HV01 Storage Replica Administrators Local Group 50 | CONTOSO-HV01 System Managed Accounts Group Local Group 51 | CONTOSO-HV01 Users Local Group 52 | 53 | Gets all local groups for the machine CONTOSO-HV01, displaying the default properties. 54 | 55 | .EXAMPLE 56 | PS C:\> Get-PspLocalGroup -ComputerName CONTOSO-APP01 | Where-Object {$_.GroupName -eq 'Administrators'} | Select-Object ComputerName,GroupName,Members 57 | 58 | ComputerName GroupName Members 59 | ------------ --------- ------- 60 | CONTOSO-APP01 Administrators Administrator 61 | 62 | Shows you all the members of the Administrators group on CONTOSO-APP01. 63 | 64 | .NOTES 65 | Name: Get-PspLocalGroup.ps1 66 | Author: Robert Prüst 67 | Module: PSP-Inventory 68 | DateCreated: 20-02-2019 69 | DateModified: 12-03-2019 70 | Blog: https://powershellpr0mpt.com 71 | 72 | .LINK 73 | https://powershellpr0mpt.com 74 | #> 75 | 76 | [OutputType('PSP.Inventory.LocalGroup')] 77 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 78 | param( 79 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 80 | [ValidateNotNullorEmpty()] 81 | [Alias('CN')] 82 | [String[]]$ComputerName = $env:COMPUTERNAME, 83 | [Parameter(ParameterSetName = 'Computer')] 84 | [PSCredential]$Credential, 85 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 86 | [Alias('Session')] 87 | [System.Management.Automation.Runspaces.PSSession[]]$PSSession 88 | ) 89 | begin { 90 | $GroupType = @{ 91 | 0x2 = 'Global Group' 92 | 0x4 = 'Local Group' 93 | 0x8 = 'Universal Group' 94 | 2147483648 = 'Security Enabled' 95 | } 96 | } 97 | process { 98 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 99 | $PSSession = @() 100 | $SessionProperties = @{ 101 | ErrorAction = 'Stop' 102 | Computername = '' 103 | } 104 | if ($Credential.Username) { 105 | $SessionProperties.Add('Credential', $Credential) 106 | } 107 | foreach ($Computer in $ComputerName) { 108 | $Computer = $Computer.toUpper() 109 | ` $SessionProperties.ComputerName = $Computer 110 | Try { 111 | $PSSession += New-PSSession @SessionProperties 112 | } 113 | catch [System.Management.Automation.Remoting.PSRemotingTransportException] { 114 | Write-Warning "[$Computer] - Unable to open PS Remoting session. Reverting to [ADSI]" 115 | try { 116 | $DomainRole = (Get-WmiObject -ComputerName $Computer -Class Win32_ComputerSystem -Property DomainRole -ErrorAction Stop).DomainRole 117 | if (!($DomainRole -match "4|5")){ 118 | $GroupInfo = ([ADSI]"WinNT://$Computer").Children | Where-Object {$_.SchemaClassName -eq 'Group'} 119 | foreach ($Group in $GroupInfo) { 120 | [PSCustomObject]@{ 121 | PSTypeName = 'PSP.Inventory.LocalGroup' 122 | ComputerName = $Computer 123 | GroupName = $Group.Name[0] 124 | Members = ((_GetLocalGroupMember -Group $Group) -join '; ') 125 | GroupType = $GroupType[[int]$Group.GroupType[0]] 126 | SID = (ConvertTo-SID -BinarySID $Group.ObjectSid[0]) 127 | InventoryDate = $InventoryDate 128 | } 129 | } 130 | } else { 131 | Write-Warning "[$Computer] - is a Domain Controller, no local groups available" 132 | } 133 | } 134 | catch { 135 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 136 | } 137 | } 138 | Catch { 139 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 140 | } 141 | } 142 | } 143 | foreach ($Session in $PSSession) { 144 | _GetLocalGroup -PSSession $Session 145 | } 146 | } 147 | End { 148 | if ($PSCmdlet.ParameterSetName -eq 'Computer' -AND $PSSession.count -gt 0) { 149 | Remove-PSSession $PSSession 150 | } 151 | } 152 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspLocalUser.ps1: -------------------------------------------------------------------------------- 1 | Function Get-PspLocalUser { 2 | <# 3 | .SYNOPSIS 4 | Get all local users for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get all local users for local or remote machines. 8 | Provides extra information about the actual user based on the user's settings. 9 | 10 | .PARAMETER ComputerName 11 | Provide the computername(s) to query. 12 | Using this parameter will create a temporary PSSession to obtain the information if available. 13 | If PowerShell remoting is not available, it will try and obtain the information through ADSI. 14 | Default value is the local machine. 15 | 16 | .PARAMETER Credential 17 | Provide the credentials for the PowerShell remoting session to be created if current credentials are not sufficient. 18 | 19 | .PARAMETER PSSession 20 | Provide the PowerShell remoting session object to query if this is already available. 21 | Once the information has been gathered, the PowerShell session will remain available for further use. 22 | 23 | .EXAMPLE 24 | PS C:\> Get-PspLocalUser -ComputerName CONTOSO-SRV01 25 | 26 | ComputerName UserName LastLogin 27 | ------------ -------- --------- 28 | CONTOSO-SRV01 Administrator 3/12/2019 8:47:17 AM 29 | CONTOSO-SRV01 DefaultAccount 30 | CONTOSO-SRV01 Guest 31 | 32 | Gets the local users for CONTOSO-SRV01, displaying the default properties. 33 | 34 | .NOTES 35 | Name: Get-PspLocalUser.ps1 36 | Author: Robert Prüst 37 | Module: PSP-Inventory 38 | DateCreated: 20-02-2019 39 | DateModified: 12-03-2019 40 | Blog: https://powershellpr0mpt.com 41 | 42 | .LINK 43 | https://powershellpr0mpt.com 44 | #> 45 | 46 | [OutputType('PSP.Inventory.LocalUser')] 47 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 48 | param( 49 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 50 | [ValidateNotNullorEmpty()] 51 | [Alias('CN')] 52 | [String[]]$ComputerName = $env:COMPUTERNAME, 53 | [Parameter(ParameterSetName = 'Computer')] 54 | [PSCredential]$Credential, 55 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 56 | [Alias('Session')] 57 | [System.Management.Automation.Runspaces.PSSession[]]$PSSession 58 | ) 59 | process { 60 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 61 | foreach ($Computer in $ComputerName) { 62 | $Computer = $Computer.toUpper() 63 | try { 64 | $DomainRole = (Get-WmiObject -ComputerName $Computer -Class Win32_ComputerSystem -Property DomainRole -ErrorAction Stop).DomainRole 65 | if (!($DomainRole -match "4|5")){ 66 | $UserInfo = ([ADSI]"WinNT://$Computer").Children | Where-Object {$_.SchemaClassName -eq 'User'} 67 | foreach ($User in $UserInfo) { 68 | [PSCustomObject]@{ 69 | PSTypeName = 'PSP.Inventory.LocalUser' 70 | ComputerName = $Computer 71 | UserName = $User.Name[0] 72 | Description = $User.Description[0] 73 | LastLogin = if ($User.LastLogin[0] -is [datetime]) {$User.LastLogin[0]}else {$null} 74 | SID = (ConvertTo-SID -BinarySID $User.ObjectSid[0]) 75 | UserFlags = (Convert-UserFlag -UserFlag $User.UserFlags[0]) 76 | InventoryDate = (Get-Date) 77 | } 78 | } 79 | } else { 80 | Write-Warning "[$Computer] - is a Domain Controller, no local users available" 81 | } 82 | } 83 | catch { 84 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 85 | } 86 | } 87 | } 88 | foreach ($Session in $PSSession) { 89 | _GetLocalUser -PSSession $Session 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspNicInfo.ps1: -------------------------------------------------------------------------------- 1 | function Get-PspNicInfo { 2 | <# 3 | .SYNOPSIS 4 | Get Network adapter information for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get Network adapter information for local or remote machines. 8 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 9 | If there's already a CIM session available, this can also be used to obtain the data. 10 | 11 | .PARAMETER ComputerName 12 | Provide the computername(s) to query. 13 | This will create a new CIM session which will be removed once the information has been gathered. 14 | Default value is the local machine. 15 | 16 | .PARAMETER Credential 17 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 18 | 19 | .PARAMETER CimSession 20 | Provide the CIM session object to query if this is already available. 21 | Once the information has been gathered, the CIM session will remain available for further use. 22 | 23 | .PARAMETER Drivers 24 | Switch parameter. 25 | If activated will try and obtain the driver information for the adapter. 26 | Do note that this will substantially increase time required. 27 | 28 | .EXAMPLE 29 | PS C:\> Get-PspNicInfo -ComputerName CONTOSO-SRV01,CONTOSO-SRV02 30 | 31 | ComputerName Alias Index IPAddress Status 32 | ------------ ----- ----- --------- ------ 33 | CONTOSO-SRV01 Ethernet 1 {192.168.14.6, fe80::a438:7d49:4f12:b000} Connected 34 | CONTOSO-SRV02 Ethernet 1 {192.168.14.7, fe80::31f3:d92a:a4b9:e3a8} Connected 35 | 36 | Gets network adapter information for both CONTOSO-SRV01 and CONTOSO-SRV02, displaying the default properties. 37 | 38 | .NOTES 39 | Name: Get-PspNicInfo.ps1 40 | Author: Robert Prüst 41 | Module: PSP-Inventory 42 | DateCreated: 20-12-2018 43 | DateModified: 12-03-2019 44 | Blog: https://powershellpr0mpt.com 45 | 46 | .LINK 47 | https://powershellpr0mpt.com 48 | #> 49 | 50 | [OutputType('PSP.Inventory.NIC')] 51 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 52 | param( 53 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 54 | [ValidateNotNullorEmpty()] 55 | [Alias('CN')] 56 | [String[]]$ComputerName = $env:COMPUTERNAME, 57 | [Parameter(ParameterSetName = 'Computer')] 58 | [PSCredential]$Credential, 59 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 60 | [Alias('Session')] 61 | [Microsoft.Management.Infrastructure.CimSession[]]$CimSession, 62 | [Switch]$Drivers 63 | ) 64 | process { 65 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 66 | $CimSession = @() 67 | $CimProperties = @{ 68 | ErrorAction = 'Stop' 69 | Computername = '' 70 | } 71 | if ($credential.Username) { 72 | $CimProperties.Add('Credential', $Credential) 73 | } 74 | foreach ($Computer in $ComputerName) { 75 | $Computer = $Computer.toUpper() 76 | ` $CimProperties.ComputerName = $Computer 77 | Try { 78 | $CimSession += New-CimSession @CimProperties 79 | } 80 | catch [Microsoft.Management.Infrastructure.CimException] { 81 | Write-Warning "[$Computer] - does not have CIM access, reverting to DCOM instead" 82 | $CimOptions = New-CimSessionOption -Protocol DCOM 83 | $CimProperties.Add('SessionOption', $CimOptions) | Out-Null 84 | try { 85 | $CimSession += New-CimSession @CimProperties 86 | } 87 | catch { 88 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 89 | } 90 | Finally { 91 | $CimProperties.Remove('SessionOption') | Out-Null 92 | } 93 | } 94 | Catch { 95 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 96 | } 97 | } 98 | } 99 | foreach ($Session in $CimSession) { 100 | $NicProperties = @{ 101 | CimSession = $Session 102 | Drivers = $false 103 | } 104 | if ($Drivers) { 105 | $NicProperties.Drivers = $true 106 | } 107 | _GetNicInfo @NicProperties 108 | } 109 | } 110 | End { 111 | if ($PSCmdlet.ParameterSetName -eq 'Computer' -AND $CimSession.count -gt 0) { 112 | Remove-Cimsession $CimSession 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspOSInfo.ps1: -------------------------------------------------------------------------------- 1 | function Get-PspOSInfo { 2 | <# 3 | .SYNOPSIS 4 | Get Operating System information for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get Operating System information for local or remote machines. 8 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 9 | If there's already a CIM session available, this can also be used to obtain the data. 10 | 11 | .PARAMETER ComputerName 12 | Provide the computername(s) to query. 13 | This will create a new CIM session which will be removed once the information has been gathered. 14 | Default value is the local machine. 15 | 16 | .PARAMETER Credential 17 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 18 | 19 | .PARAMETER CimSession 20 | Provide the CIM session object to query if this is already available. 21 | Once the information has been gathered, the CIM session will remain available for further use. 22 | 23 | .EXAMPLE 24 | PS C:\> Get-PspOSInfo -ComputerName CONTOSO-SRV01,CONTOSO-SRV02 25 | 26 | ComputerName Caption Version OSArchitecture LastReboot 27 | ------------ ------- ------- -------------- ---------- 28 | CONTOSO-SRV01 Microsoft Windows Server 2016 Standard 10.0.14393 64-bit 3/4/2019 1:41:07 PM 29 | CONTOSO-SRV02 Microsoft Windows Server 2019 Standard 10.0.17763 64-bit 3/4/2019 1:41:25 PM 30 | 31 | Gets Operating system information for CONTOSO-SRV01 and CONTOSO-SRV02, displaying the default properties. 32 | 33 | .EXAMPLE 34 | PS C:\> Get-PspOSInfo -ComputerName CONTOSO-WEB01 | Format-List 35 | 36 | ComputerName : CONTOSO-WEB01 37 | Caption : Microsoft Windows Server 2016 Standard 38 | Version : 10.0.14393 39 | ServicePack : 0.0 40 | ProductKey : 41 | LastReboot : 3/4/2019 1:41:07 PM 42 | OSArchitecture : 64-bit 43 | TimeZone : (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna 44 | PageFile : 45 | PageFileSizeGB : 0 46 | InventoryDate : 3/12/2019 9:56:50 AM 47 | 48 | Gets the Operating system information for CONTOSO-WEB01 and shows all collected properties. 49 | 50 | .NOTES 51 | Name: Get-PspOSInfo.ps1 52 | Author: Robert Prüst 53 | Module: PSP-Inventory 54 | DateCreated: 20-02-2019 55 | DateModified: 12-03-2019 56 | Blog: https://powershellpr0mpt.com 57 | 58 | .LINK 59 | https://powershellpr0mpt.com 60 | #> 61 | 62 | [OutputType('PSP.Inventory.OperatingSystemInfo')] 63 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 64 | param( 65 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 66 | [ValidateNotNullorEmpty()] 67 | [Alias('CN')] 68 | [String[]]$ComputerName = $env:COMPUTERNAME, 69 | [Parameter(ParameterSetName = 'Computer')] 70 | [PSCredential]$Credential, 71 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 72 | [Alias('Session')] 73 | [Microsoft.Management.Infrastructure.CimSession[]]$CimSession 74 | ) 75 | process { 76 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 77 | $CimSession = @() 78 | $CimProperties = @{ 79 | ErrorAction = 'Stop' 80 | Computername = '' 81 | } 82 | if ($credential.Username) { 83 | $CimProperties.Add('Credential', $Credential) 84 | } 85 | foreach ($Computer in $ComputerName) { 86 | $Computer = $Computer.toUpper() 87 | ` $CimProperties.ComputerName = $Computer 88 | Try { 89 | $CimSession += New-CimSession @CimProperties 90 | } 91 | catch [Microsoft.Management.Infrastructure.CimException] { 92 | Write-Warning "[$Computer] - does not have CIM access, reverting to DCOM instead" 93 | $CimOptions = New-CimSessionOption -Protocol DCOM 94 | $CimProperties.Add('SessionOption', $CimOptions) | Out-Null 95 | try { 96 | $CimSession += New-CimSession @CimProperties 97 | } 98 | catch { 99 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 100 | } 101 | Finally { 102 | $CimProperties.Remove('SessionOption') | Out-Null 103 | } 104 | } 105 | Catch { 106 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 107 | } 108 | } 109 | } 110 | foreach ($Session in $CimSession) { 111 | _GetOSInfo -Cimsession $Session 112 | } 113 | } 114 | End { 115 | if ($PSCmdlet.ParameterSetName -eq 'Computer' -AND $CimSession.count -gt 0) { 116 | Remove-Cimsession $CimSession 117 | } 118 | } 119 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspScheduledTask.ps1: -------------------------------------------------------------------------------- 1 | Function Get-PspScheduledTask { 2 | <# 3 | .SYNOPSIS 4 | Get Scheduled task information for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get Scheduled task information for local or remote machines. 8 | Will get all scheduled tasks in the root folder. 9 | 10 | .PARAMETER ComputerName 11 | Provide the computername(s) to query. 12 | Default value is the local machine. 13 | 14 | .EXAMPLE 15 | PS C:\> Get-PspScheduledTask -ComputerName CONTOSO-SRV01,CONTOSO-WEB01,CONTOSO-APP01 16 | 17 | ComputerName Task Enabled State LastResult 18 | ------------ ---- ------- ----- ---------- 19 | CONTOSO-SRV01 Optimize Start Menu Cache Files-S-1-5-21-2130384611-3847849876-2318412143-500 False Disabled Successfully completed 20 | CONTOSO-WEB01 notepad False Disabled Successfully completed 21 | CONTOSO-APP01 GoogleUpdateTaskMachineCore True Ready Successfully completed 22 | CONTOSO-APP01 GoogleUpdateTaskMachineUA True Ready Successfully completed 23 | 24 | Gets the Scheduled Tasks for CONTOSO-SRV01, CONTOSO-WEB01 and CONTOSO-APP01, displaying the default properties. 25 | 26 | .NOTES 27 | Name: Get-PspScheduledTask.ps1 28 | Author: Robert Prüst 29 | Module: PSP-Inventory 30 | DateCreated: 23-02-2019 31 | DateModified: 12-03-2019 32 | Blog: https://powershellpr0mpt.com 33 | 34 | .LINK 35 | https://powershellpr0mpt.com 36 | #> 37 | 38 | [OutputType('PSP.Inventory.ScheduledTask')] 39 | [cmdletbinding()] 40 | param ( 41 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] 42 | [ValidateNotNullorEmpty()] 43 | [Alias('CN')] 44 | [string[]]$ComputerName = $env:COMPUTERNAME 45 | ) 46 | begin { 47 | $ST = New-Object -ComObject Schedule.Service 48 | } 49 | process { 50 | foreach ($Computer in $ComputerName) { 51 | $Computer = $Computer.ToUpper() 52 | try { 53 | $ST.Connect($Computer) 54 | $Root = $ST.GetFolder("\") 55 | @($Root.GetTasks(0)) | ForEach-Object { 56 | $xml = ([xml]$_.xml).task 57 | [PSCustomObject] @{ 58 | PSTypeName = 'PSP.Inventory.ScheduledTask' 59 | ComputerName = $Computer 60 | Task = $_.Name 61 | Author = $xml.RegistrationInfo.Author 62 | RunAs = $xml.Principals.Principal.UserId 63 | Enabled = $_.Enabled 64 | State = Switch ($_.State) { 65 | 0 {'Unknown'} 66 | 1 {'Disabled'} 67 | 2 {'Queued'} 68 | 3 {'Ready'} 69 | 4 {'Running'} 70 | } 71 | LastTaskResult = Switch ($_.LastTaskResult) { 72 | 0x0 {"Successfully completed"} 73 | 0x1 {"Incorrect function called"} 74 | 0x2 {"File not found"} 75 | 0xa {"Environment is not correct"} 76 | 0x41300 {"Task is ready to run at its next scheduled time"} 77 | 0x41301 {"Task is currently running"} 78 | 0x41302 {"Task is disabled"} 79 | 0x41303 {"Task has not yet run"} 80 | 0x41304 {"There are no more runs scheduled for this task"} 81 | 0x41306 {"Task is terminated"} 82 | 0x00041307 {"Either the task has no triggers or the existing triggers are disabled or not set"} 83 | 0x00041308 {"Event triggers do not have set run times"} 84 | 0x80041309 {"A task's trigger is not found"} 85 | 0x8004130A {"One or more of the properties required to run this task have not been set"} 86 | 0x8004130B {"There is no running instance of the task"} 87 | 0x8004130C {"The Task * SCHEDuler service is not installed on this computer"} 88 | 0x8004130D {"The task object could not be opened"} 89 | 0x8004130E {"The object is either an invalid task object or is not a task object"} 90 | 0x8004130F {"No account information could be found in the Task * SCHEDuler security database for the task indicated"} 91 | 0x80041310 {"Unable to establish existence of the account specified"} 92 | 0x80041311 {"Corruption was detected in the Task * SCHEDuler security database"} 93 | 0x80041312 {"Task * SCHEDuler security services are available only on Windows NT"} 94 | 0x80041313 {"The task object version is either unsupported or invalid"} 95 | 0x80041314 {"The task has been configured with an unsupported combination of account settings and run time options"} 96 | 0x80041315 {"The Task * SCHEDuler Service is not running"} 97 | 0x80041316 {"The task XML contains an unexpected node"} 98 | 0x80041317 {"The task XML contains an element or attribute from an unexpected namespace"} 99 | 0x80041318 {"The task XML contains a value which is incorrectly formatted or out of range"} 100 | 0x80041319 {"The task XML is missing a required element or attribute"} 101 | 0x8004131A {"The task XML is malformed"} 102 | 0x0004131B {"The task is registered, but not all specified triggers will start the task"} 103 | 0x0004131C {"The task is registered, but may fail to start"} 104 | 0x8004131D {"The task XML contains too many nodes of the same type"} 105 | 0x8004131E {"The task cannot be started after the trigger end boundary"} 106 | 0x8004131F {"An instance of this task is already running"} 107 | 0x80041320 {"The task will not run because the user is not logged on"} 108 | 0x80041321 {"The task image is corrupt or has been tampered with"} 109 | 0x80041322 {"The Task * SCHEDuler service is not available"} 110 | 0x80041323 {"The Task * SCHEDuler service is too busy to handle your request"} 111 | 0x80041324 {"The Task * SCHEDuler service attempted to run the task, but the task did not run due to one of the constraints in the task definition"} 112 | 0x00041325 {"The Task * SCHEDuler service has asked the task to run"} 113 | 0x80041326 {"The task is disabled"} 114 | 0x80041327 {"The task has properties that are not compatible with earlier versions of Windows"} 115 | 0x80041328 {"The task settings do not allow the task to start on demand"} 116 | Default {[string]$_} 117 | } 118 | Command = $xml.Actions.Exec.Command 119 | Arguments = $xml.Actions.Exec.Arguments 120 | StartDirectory = $xml.Actions.Exec.WorkingDirectory 121 | Hidden = $xml.Settings.Hidden 122 | InventoryDate = (Get-Date) 123 | } 124 | } 125 | } 126 | catch { 127 | Write-Warning "[$Computer] - Unable to access Scheduled Task Information. $_" 128 | } 129 | } 130 | } 131 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspSecurityUpdate.ps1: -------------------------------------------------------------------------------- 1 | function Get-PspSecurityUpdate { 2 | <# 3 | .SYNOPSIS 4 | Get all the security update information for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get all the security update information for local or remote machines. 8 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 9 | If there's already a CIM session available, this can also be used to obtain the data. 10 | 11 | .PARAMETER ComputerName 12 | Provide the computername(s) to query. 13 | This will create a new CIM session which will be removed once the information has been gathered. 14 | Default value is the local machine. 15 | 16 | .PARAMETER Credential 17 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 18 | 19 | .PARAMETER CimSession 20 | Provide the CIM session object to query if this is already available. 21 | Once the information has been gathered, the CIM session will remain available for further use. 22 | 23 | .EXAMPLE 24 | PS C:\> Get-PspSecurityUpdate -ComputerName CONTOSO-SRV01,CONTOSO-SRV02 25 | 26 | ComputerName Type KBFile InstallDate 27 | ------------ ---- ------ ----------- 28 | CONTOSO-SRV01 Update KB4049065 2/2/2018 12:00:00 AM 29 | CONTOSO-SRV01 Security Update KB4048953 2/2/2018 12:00:00 AM 30 | CONTOSO-SRV02 Update KB4464455 10/29/2018 12:00:00 AM 31 | 32 | Gets the installed security updates for CONTOSO-SRV01 and CONTOSO-SRV02, displaying the default properties. 33 | 34 | .NOTES 35 | Name: Get-PspSecurityUpdate.ps1 36 | Author: Robert Prüst 37 | Module: PSP-Inventory 38 | DateCreated: 21-02-2019 39 | DateModified: 12-03-2019 40 | Blog: https://powershellpr0mpt.com 41 | 42 | .LINK 43 | https://powershellpr0mpt.com 44 | #> 45 | 46 | [OutputType('PSP.Inventory.SecurityUpdate')] 47 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 48 | param( 49 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 50 | [ValidateNotNullorEmpty()] 51 | [Alias('CN')] 52 | [String[]]$ComputerName = $env:COMPUTERNAME, 53 | [Parameter(ParameterSetName = 'Computer')] 54 | [PSCredential]$Credential, 55 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 56 | [Alias('Session')] 57 | [Microsoft.Management.Infrastructure.CimSession[]]$CimSession 58 | ) 59 | process { 60 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 61 | $CimSession = @() 62 | $CimProperties = @{ 63 | ErrorAction = 'Stop' 64 | Computername = '' 65 | } 66 | if ($credential.Username) { 67 | $CimProperties.Add('Credential', $Credential) 68 | } 69 | foreach ($Computer in $ComputerName) { 70 | $Computer = $Computer.toUpper() 71 | ` $CimProperties.ComputerName = $Computer 72 | Try { 73 | $CimSession += New-CimSession @CimProperties 74 | } 75 | catch [Microsoft.Management.Infrastructure.CimException] { 76 | Write-Warning "[$Computer] - does not have CIM access, reverting to DCOM instead" 77 | $CimOptions = New-CimSessionOption -Protocol DCOM 78 | $CimProperties.Add('SessionOption', $CimOptions) | Out-Null 79 | try { 80 | $CimSession += New-CimSession @CimProperties 81 | } 82 | catch { 83 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 84 | } 85 | Finally { 86 | $CimProperties.Remove('SessionOption') | Out-Null 87 | } 88 | } 89 | Catch { 90 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 91 | } 92 | } 93 | } 94 | foreach ($Session in $CimSession) { 95 | _GetUpdateInfo -Cimsession $Session 96 | } 97 | } 98 | End { 99 | if ($PSCmdlet.ParameterSetName -eq 'Computer' -AND $CimSession.count -gt 0) { 100 | Remove-Cimsession $CimSession 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspServerRole.ps1: -------------------------------------------------------------------------------- 1 | function Get-PspServerRole { 2 | <# 3 | .SYNOPSIS 4 | Get Server Roles for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get Server Roles for local or remote machines. 8 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 9 | If there's already a CIM session available, this can also be used to obtain the data. 10 | 11 | .PARAMETER ComputerName 12 | Provide the computername(s) to query. 13 | This will create a new CIM session which will be removed once the information has been gathered. 14 | Default value is the local machine. 15 | 16 | .PARAMETER Credential 17 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 18 | 19 | .PARAMETER CimSession 20 | Provide the CIM session object to query if this is already available. 21 | Once the information has been gathered, the CIM session will remain available for further use. 22 | 23 | .EXAMPLE 24 | PS C:\> Get-PspServerRole -ComputerName CONTOSO-SRV01,CONTOSO-SRV02 25 | 26 | ComputerName RoleId Name InventoryDate 27 | ------------ ------ ---- ------------- 28 | CONTOSO-SRV01 481 File and Storage Services 3/12/2019 10:18:40 AM 29 | CONTOSO-SRV01 487 SMB 1.0/CIFS File Sharing Support 3/12/2019 10:18:40 AM 30 | CONTOSO-SRV01 418 .NET Framework 4.6 3/12/2019 10:18:40 AM 31 | CONTOSO-SRV01 466 .NET Framework 4.6 Features 3/12/2019 10:18:40 AM 32 | CONTOSO-SRV01 420 WCF Services 3/12/2019 10:18:40 AM 33 | CONTOSO-SRV01 425 TCP Port Sharing 3/12/2019 10:18:40 AM 34 | CONTOSO-SRV01 412 Windows PowerShell 5.1 3/12/2019 10:18:40 AM 35 | CONTOSO-SRV01 417 Windows PowerShell 3/12/2019 10:18:40 AM 36 | CONTOSO-SRV01 482 Storage Services 3/12/2019 10:18:40 AM 37 | CONTOSO-SRV01 1003 Windows Defender 3/12/2019 10:18:40 AM 38 | CONTOSO-SRV01 1020 Windows Defender Features 3/12/2019 10:18:40 AM 39 | CONTOSO-SRV01 340 WoW64 Support 3/12/2019 10:18:40 AM 40 | CONTOSO-SRV02 481 File and Storage Services 3/12/2019 10:18:40 AM 41 | CONTOSO-SRV02 418 .NET Framework 4.7 3/12/2019 10:18:41 AM 42 | CONTOSO-SRV02 466 .NET Framework 4.7 Features 3/12/2019 10:18:41 AM 43 | CONTOSO-SRV02 420 WCF Services 3/12/2019 10:18:41 AM 44 | CONTOSO-SRV02 425 TCP Port Sharing 3/12/2019 10:18:41 AM 45 | CONTOSO-SRV02 412 Windows PowerShell 5.1 3/12/2019 10:18:41 AM 46 | CONTOSO-SRV02 417 Windows PowerShell 3/12/2019 10:18:41 AM 47 | CONTOSO-SRV02 482 Storage Services 3/12/2019 10:18:41 AM 48 | CONTOSO-SRV02 1043 System Data Archiver 3/12/2019 10:18:41 AM 49 | CONTOSO-SRV02 1003 Windows Defender Antivirus 3/12/2019 10:18:41 AM 50 | CONTOSO-SRV02 340 WoW64 Support 3/12/2019 10:18:41 AM 51 | 52 | Gets the installed server roles for CONTOSO-SRV01 and CONTOSO-SRV02. 53 | 54 | .NOTES 55 | Name: Get-PspServerRole.ps1 56 | Author: Robert Prüst 57 | Module: PSP-Inventory 58 | DateCreated: 22-12-2018 59 | DateModified: 12-03-2019 60 | Blog: https://powershellpr0mpt.com 61 | 62 | .LINK 63 | https://powershellpr0mpt.com 64 | #> 65 | 66 | [OutputType('PSP.Inventory.ServerRole')] 67 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 68 | param( 69 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 70 | [ValidateNotNullorEmpty()] 71 | [Alias('CN')] 72 | [String[]]$ComputerName = $env:COMPUTERNAME, 73 | [Parameter(ParameterSetName = 'Computer')] 74 | [PSCredential]$Credential, 75 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 76 | [Alias('Session')] 77 | [Microsoft.Management.Infrastructure.CimSession[]]$CimSession 78 | ) 79 | process { 80 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 81 | $CimSession = @() 82 | $CimProperties = @{ 83 | ErrorAction = 'Stop' 84 | Computername = '' 85 | } 86 | if ($credential.Username) { 87 | $CimProperties.Add('Credential', $Credential) 88 | } 89 | foreach ($Computer in $ComputerName) { 90 | $Computer = $Computer.toUpper() 91 | ` $CimProperties.ComputerName = $Computer 92 | Try { 93 | $CimSession += New-CimSession @CimProperties 94 | } 95 | catch [Microsoft.Management.Infrastructure.CimException] { 96 | Write-Warning "[$Computer] - does not have CIM access, reverting to DCOM instead" 97 | $CimOptions = New-CimSessionOption -Protocol DCOM 98 | $CimProperties.Add('SessionOption', $CimOptions) | Out-Null 99 | try { 100 | $CimSession += New-CimSession @CimProperties 101 | } 102 | catch { 103 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 104 | } 105 | Finally { 106 | $CimProperties.Remove('SessionOption') | Out-Null 107 | } 108 | } 109 | Catch { 110 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 111 | } 112 | } 113 | } 114 | foreach ($Session in $CimSession) { 115 | _GetRoleInfo -Cimsession $Session 116 | } 117 | } 118 | End { 119 | if ($PSCmdlet.ParameterSetName -eq 'Computer' -AND $CimSession.count -gt 0) { 120 | Remove-Cimsession $CimSession 121 | } 122 | } 123 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspSoftware.ps1: -------------------------------------------------------------------------------- 1 | Function Get-PspSoftware { 2 | <# 3 | .SYNOPSIS 4 | Get the installed software for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get the installed software for local or remote machines. 8 | Will try and access the required data through a PowerShell remoting session, but in case this fails reverts to RemoteRegistry. 9 | This does however require RemoteRegistry to be enabled on the machine. 10 | Will look for both x86 and x64 installed paths. 11 | 12 | .PARAMETER ComputerName 13 | Provide the computername(s) to query. 14 | Using this parameter will create a temporary PSSession to obtain the information if available. 15 | If PowerShell remoting is not available, it will try and obtain the information through ADSI. 16 | Default value is the local machine. 17 | 18 | .PARAMETER Credential 19 | Provide the credentials for the PowerShell remoting session to be created if current credentials are not sufficient. 20 | 21 | .PARAMETER PSSession 22 | Provide the PowerShell remoting session object to query if this is already available. 23 | Once the information has been gathered, the PowerShell session will remain available for further use. 24 | 25 | .EXAMPLE 26 | PS C:\> Get-PspSoftware -ComputerName CONTOSO-SRV01,CONTOSO-WEB01,CONTOSO-APP01 27 | 28 | ComputerName : CONTOSO-SRV01 29 | DisplayName : Google Chrome 30 | Version : 72.0.3626.121 31 | InstallDate : 3/11/2019 12:00:00 AM 32 | Publisher : Google LLC 33 | UninstallString : MsiExec.exe /X{0C8D8E7A-485A-39D9-82C9-DF0955BE2A57} 34 | InstallLocation : 35 | InstallSource : C:\Users\Administrator\AppData\Local\Temp\1\Temp1_GoogleChromeEnterpriseBundle64.zip\Installers\ 36 | HelpLink : 37 | EstimatedSizeMB : 54.5 38 | InventoryDate : 3/12/2019 10:25:45 AM 39 | 40 | ComputerName : CONTOSO-SRV01 41 | DisplayName : Google Update Helper 42 | Version : 1.3.33.23 43 | InstallDate : 3/11/2019 12:00:00 AM 44 | Publisher : Google Inc. 45 | UninstallString : MsiExec.exe /I{60EC980A-BDA2-4CB6-A427-B07A5498B4CA} 46 | InstallLocation : 47 | InstallSource : C:\Program Files (x86)\Google\Update\1.3.33.23\ 48 | HelpLink : 49 | EstimatedSizeMB : 0.04 50 | InventoryDate : 3/12/2019 10:25:45 AM 51 | 52 | ComputerName : CONTOSO-WEB01 53 | DisplayName : VLC media player 54 | Version : 3.0.6 55 | InstallDate : 56 | Publisher : VideoLAN 57 | UninstallString : "C:\Program Files (x86)\VideoLAN\VLC\uninstall.exe" 58 | InstallLocation : C:\Program Files (x86)\VideoLAN\VLC 59 | InstallSource : 60 | HelpLink : 61 | EstimatedSize : 0 62 | InventoryDate : 3/12/2019 10:25:45 AM 63 | 64 | ComputerName : CONTOSO-APP01 65 | DisplayName : Notepad++ (32-bit x86) 66 | Version : 7.6.4 67 | InstallDate : 68 | Publisher : Notepad++ Team 69 | UninstallString : C:\Program Files (x86)\Notepad++\uninstall.exe 70 | InstallLocation : 71 | InstallSource : 72 | HelpLink : 73 | EstimatedSize : 4.35 74 | InventoryDate : 3/12/2019 10:25:45 AM 75 | 76 | Gets the installed software for CONTOSO-SRV01, CONTOSO-WEB01 and CONTOSO-APP01. 77 | 78 | 79 | .NOTES 80 | Name: Get-PspSoftware.ps1 81 | Author: Robert Prüst 82 | Module: PSP-Inventory 83 | DateCreated: 21-02-2019 84 | DateModified: 12-03-2019 85 | Blog: http://powershellpr0mpt.com 86 | 87 | .LINK 88 | http://powershellpr0mpt.com 89 | #> 90 | 91 | [OutputType('PSP.Inventory.Software')] 92 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 93 | param( 94 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 95 | [ValidateNotNullorEmpty()] 96 | [Alias('CN')] 97 | [String[]]$ComputerName = $env:COMPUTERNAME, 98 | [Parameter(ParameterSetName = 'Computer')] 99 | [PSCredential]$Credential, 100 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 101 | [Alias('Session')] 102 | [System.Management.Automation.Runspaces.PSSession[]]$PSSession 103 | ) 104 | process { 105 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 106 | $PSSession = @() 107 | $SessionProperties = @{ 108 | ErrorAction = 'Stop' 109 | Computername = '' 110 | } 111 | if ($Credential.Username) { 112 | $SessionProperties.Add('Credential', $Credential) 113 | } 114 | foreach ($Computer in $ComputerName) { 115 | $Computer = $Computer.toUpper() 116 | ` $SessionProperties.ComputerName = $Computer 117 | Try { 118 | $PSSession += New-PSSession @SessionProperties 119 | } 120 | catch [System.Management.Automation.Remoting.PSRemotingTransportException] { 121 | Write-Warning "[$Computer] - Unable to open PS Remoting session. Reverting to Remote Registry" 122 | try { 123 | $Paths = @("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", "SOFTWARE\\Wow6432node\\Microsoft\\Windows\\CurrentVersion\\Uninstall") 124 | foreach ($Path in $Paths) { 125 | Write-Verbose "[$Computer] - Checking Registry Path: $Path" 126 | $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computer, 'Registry64') 127 | try { 128 | $regkey = $reg.OpenSubKey($Path) 129 | $subkeys = $regkey.GetSubKeyNames() 130 | foreach ($key in $subkeys) { 131 | Write-Verbose "[$Computer] - Checking Registry Key: $Key" 132 | $thisKey = $Path + "\\" + $key 133 | try { 134 | $thisSubKey = $reg.OpenSubKey($thisKey) 135 | $DisplayName = $thisSubKey.getValue("DisplayName") 136 | if ($DisplayName -AND $DisplayName -notmatch '^Update for|rollup|^Security Update|^Service Pack|^HotFix') { 137 | $Date = $thisSubKey.GetValue('InstallDate') 138 | if ($Date) { 139 | try { 140 | $Date = [datetime]::ParseExact($Date, 'yyyyMMdd', $Null) 141 | } 142 | catch { 143 | $Date = $Null 144 | } 145 | } 146 | $Publisher = try { 147 | $thisSubKey.GetValue('Publisher').Trim() 148 | } 149 | catch { 150 | $thisSubKey.GetValue('Publisher') 151 | } 152 | $Version = try { 153 | $thisSubKey.GetValue('DisplayVersion').TrimEnd(([char[]](32, 0))) 154 | } 155 | catch { 156 | $thisSubKey.GetValue('DisplayVersion') 157 | } 158 | $UninstallString = try { 159 | $thisSubKey.GetValue('UninstallString').Trim() 160 | } 161 | catch { 162 | $thisSubKey.GetValue('UninstallString') 163 | } 164 | $InstallLocation = try { 165 | $thisSubKey.GetValue('InstallLocation').Trim() 166 | } 167 | catch { 168 | $thisSubKey.GetValue('InstallLocation') 169 | } 170 | $InstallSource = try { 171 | $thisSubKey.GetValue('InstallSource').Trim() 172 | } 173 | catch { 174 | $thisSubKey.GetValue('InstallSource') 175 | } 176 | $HelpLink = try { 177 | $thisSubKey.GetValue('HelpLink').Trim() 178 | } 179 | catch { 180 | $thisSubKey.GetValue('HelpLink') 181 | } 182 | [PSCustomObject]@{ 183 | PSTypeName = 'PSP.Inventory.Software' 184 | ComputerName = $Computer 185 | DisplayName = $DisplayName 186 | Version = $Version 187 | InstallDate = $Date 188 | Publisher = $Publisher 189 | UninstallString = $UninstallString 190 | InstallLocation = $InstallLocation 191 | InstallSource = $InstallSource 192 | HelpLink = $HelpLink 193 | EstimatedSizeMB = [math]::Round(($thisSubKey.GetValue('EstimatedSize') * 1024) / 1MB, 2) 194 | InventoryDate = (Get-Date) 195 | } 196 | } 197 | } 198 | catch { 199 | Write-Warning "[$Computer] - Unable to access key: $Key " 200 | } 201 | } 202 | } 203 | catch {} 204 | $reg.Close() 205 | } 206 | } 207 | catch { 208 | Write-Error "[$Computer] - Unable to open Remote Registry" 209 | Continue 210 | } 211 | 212 | } 213 | catch { 214 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 215 | } 216 | } 217 | } 218 | foreach ($Session in $PSSession) { 219 | _GetSoftwareInfo -PSSession $Session 220 | } 221 | } 222 | End { 223 | if ($PSCmdlet.ParameterSetName -eq 'Computer' -AND $PSSession.count -gt 0) { 224 | Remove-PSSession $PSSession 225 | } 226 | } 227 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspSysInfo.ps1: -------------------------------------------------------------------------------- 1 | function Get-PspSysInfo { 2 | <# 3 | .SYNOPSIS 4 | Get System information for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Get System information for local or remote machines. 8 | Will query default information about the actual system, such as CPU & Memory and if it's virtual or physical 9 | Tries to create a CIM session to obtain information, but will revert to DCOM if CIM is not available. 10 | If there's already a CIM session available, this can also be used to obtain the data. 11 | 12 | .PARAMETER ComputerName 13 | Provide the computername(s) to query. 14 | This will create a new CIM session which will be removed once the information has been gathered. 15 | Default value is the local machine. 16 | 17 | .PARAMETER Credential 18 | Provide the credentials for the CIM session to be created if current credentials are not sufficient. 19 | 20 | .PARAMETER CimSession 21 | Provide the CIM session object to query if this is already available. 22 | Once the information has been gathered, the CIM session will remain available for further use. 23 | 24 | .EXAMPLE 25 | PS C:\> Get-PspSysInfo -ComputerName CONTOSO-SRV01,CONTOSO-SRV02 26 | 27 | ComputerName Model SerialNumber CPUCores CPULogical MemoryGB 28 | ------------ ----- ------------ -------- ---------- -------- 29 | CONTOSO-SRV01 Virtual Machine 6656-6324-2091-0011-9109-1646-89 1 2 0 30 | CONTOSO-SRV02 Virtual Machine 8945-5393-3426-8378-9495-3257-53 1 2 1 31 | 32 | Gets the installed server roles for CONTOSO-SRV01 and CONTOSO-SRV02, displaying the default properties. 33 | 34 | .NOTES 35 | Name: Get-PspSysInfo.ps1 36 | Author: Robert Prüst 37 | Module: PSP-Inventory 38 | DateCreated: 24-02-2019 39 | DateModified: 12-03-2019 40 | Blog: https://powershellpr0mpt.com 41 | 42 | .LINK 43 | https://powershellpr0mpt.com 44 | #> 45 | 46 | [OutputType('PSP.Inventory.SystemInfo')] 47 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 48 | param( 49 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 50 | [ValidateNotNullorEmpty()] 51 | [Alias('CN')] 52 | [String[]]$ComputerName = $env:COMPUTERNAME, 53 | [Parameter(ParameterSetName = 'Computer')] 54 | [PSCredential]$Credential, 55 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 56 | [Alias('Session')] 57 | [Microsoft.Management.Infrastructure.CimSession[]]$CimSession 58 | ) 59 | process { 60 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 61 | $CimSession = @() 62 | $CimProperties = @{ 63 | ErrorAction = 'Stop' 64 | Computername = '' 65 | } 66 | if ($credential.Username) { 67 | $CimProperties.Add('Credential', $Credential) 68 | } 69 | foreach ($Computer in $ComputerName) { 70 | $Computer = $Computer.toUpper() 71 | ` $CimProperties.ComputerName = $Computer 72 | Try { 73 | $CimSession += New-CimSession @CimProperties 74 | } 75 | catch [Microsoft.Management.Infrastructure.CimException] { 76 | Write-Warning "[$Computer] - does not have CIM access, reverting to DCOM instead" 77 | $CimOptions = New-CimSessionOption -Protocol DCOM 78 | $CimProperties.Add('SessionOption', $CimOptions) | Out-Null 79 | try { 80 | $CimSession += New-CimSession @CimProperties 81 | } 82 | catch { 83 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 84 | } 85 | Finally { 86 | $CimProperties.Remove('SessionOption') | Out-Null 87 | } 88 | } 89 | Catch { 90 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 91 | } 92 | } 93 | } 94 | foreach ($Session in $CimSession) { 95 | _GetSysInfo -Cimsession $Session 96 | } 97 | } 98 | End { 99 | if ($PSCmdlet.ParameterSetName -eq 'Computer' -AND $CimSession.count -gt 0) { 100 | Remove-Cimsession $CimSession 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /PSP-Inventory/public/Get-PspVMInfo.ps1: -------------------------------------------------------------------------------- 1 | Function Get-PspVMInfo { 2 | <# 3 | .SYNOPSIS 4 | Gets virtualization information for local or remote machines. 5 | 6 | .DESCRIPTION 7 | Gets virtualization information for local or remote machines. 8 | Will try and access the required data through a PowerShell remoting session, but in case this fails reverts to RemoteRegistry. 9 | This does however require RemoteRegistry to be enabled on the machine. 10 | 11 | .PARAMETER ComputerName 12 | Provide the computername(s) to query. 13 | Using this parameter will create a temporary PSSession to obtain the information if available. 14 | If PowerShell remoting is not available, it will try and obtain the information through ADSI. 15 | Default value is the local machine. 16 | 17 | .PARAMETER Credential 18 | Provide the credentials for the PowerShell remoting session to be created if current credentials are not sufficient. 19 | 20 | .PARAMETER PSSession 21 | Provide the PowerShell remoting session object to query if this is already available. 22 | Once the information has been gathered, the PowerShell session will remain available for further use. 23 | 24 | .EXAMPLE 25 | PS C:\> Get-PspVMInfo -ComputerName CONTOSO-SRV01,CONTOSO-WEB01,CONTOSO-APP01 | Format-List 26 | 27 | ComputerName : CONTOSO-SRV01 28 | HVIntegrationServicesRunning : True 29 | HVHostName : hv01.contoso.com 30 | HVVMName : HV-VM01 31 | VMWareToolsRunning : False 32 | InventoryDate : 3/16/2019 1:44:10 AM 33 | 34 | ComputerName : CONTOSO-WEB01 35 | HVIntegrationServicesRunning : True 36 | HVHostName : hv01.contoso.com 37 | HVVMName : HV-VM02 38 | VMWareToolsRunning : False 39 | InventoryDate : 3/16/2019 1:44:10 AM 40 | 41 | ComputerName : CONTOSO-APP01 42 | HVIntegrationServicesRunning : True 43 | HVHostName : hv02.contoso.com 44 | HVVMName : HV-VM12 45 | VMWareToolsRunning : False 46 | InventoryDate : 3/16/2019 1:44:10 AM 47 | 48 | Gets the virtualization information for CONTOSO-SRV01, CONTOSO-WEB01 and CONTOSO-APP01. 49 | 50 | .NOTES 51 | Name: Get-PspVMInfo.ps1 52 | Author: Robert Prüst 53 | Module: PSP-Inventory 54 | DateCreated: 16-03-2019 55 | DateModified: 16-03-2019 56 | Blog: http://powershellpr0mpt.com 57 | 58 | .LINK 59 | http://powershellpr0mpt.com 60 | #> 61 | 62 | [OutputType('PSP.Inventory.VMInfo')] 63 | [Cmdletbinding(DefaultParameterSetName = 'Computer')] 64 | param( 65 | [Parameter(Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Computer')] 66 | [ValidateNotNullorEmpty()] 67 | [Alias('CN')] 68 | [String[]]$ComputerName = $env:COMPUTERNAME, 69 | [Parameter(ParameterSetName = 'Computer')] 70 | [PSCredential]$Credential, 71 | [Parameter(Position = 0, ValueFromPipeline = $true, ParameterSetName = 'Session')] 72 | [Alias('Session')] 73 | [System.Management.Automation.Runspaces.PSSession[]]$PSSession 74 | ) 75 | process { 76 | if ($PSCmdlet.ParameterSetName -eq 'Computer') { 77 | $PSSession = @() 78 | $SessionProperties = @{ 79 | ErrorAction = 'Stop' 80 | Computername = '' 81 | } 82 | if ($Credential.Username) { 83 | $SessionProperties.Add('Credential', $Credential) 84 | } 85 | foreach ($Computer in $ComputerName) { 86 | $Computer = $Computer.toUpper() 87 | ` $SessionProperties.ComputerName = $Computer 88 | Try { 89 | $PSSession += New-PSSession @SessionProperties 90 | } 91 | catch [System.Management.Automation.Remoting.PSRemotingTransportException] { 92 | Write-Warning "[$Computer] - Unable to open PS Remoting session. Reverting to Remote Registry" 93 | try { 94 | $HVService = Get-Service -ComputerName $Computer -DisplayName '*Hyper-V*' -ErrorAction SilentlyContinue | Where-Object {$_.Status -eq 'Running'} 95 | $VMService = Get-Service -ComputerName $Computer -Name VMTools -ErrorAction SilentlyContinue 96 | $HVHostName = $null 97 | $HVVMName = $null 98 | $Path = @("SOFTWARE\\Microsoft\\Virtual Machine\\Guest\\Parameters") 99 | Write-Verbose "[$Computer] - Checking Registry Path: $Path" 100 | $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Computer, 'Registry64') 101 | try { 102 | Write-Verbose "[$Computer] - Checking Registry Key: $Path" 103 | $regkey = $reg.OpenSubKey($Path) 104 | try { 105 | $HVHostName = $regkey.getValue("PhysicalHostNameFullyQualified") 106 | $HVVMName = $regkey.getValue("VirtualMachineName") 107 | } 108 | catch { 109 | Write-Warning "[$Computer] - Unable to access key: $Path " 110 | } 111 | } 112 | catch {} 113 | $reg.Close() 114 | 115 | [PSCustomObject]@{ 116 | PSTypeName = 'PSP.Inventory.VMInfo' 117 | ComputerName = $Computer 118 | HVIntegrationServicesRunning = if ($HVService) {$true}else {$false} 119 | HVHostName = $HVHostName 120 | HVVMName = $HVVMName 121 | VMWareToolsRunning = if ($VMService) {$true}else {$false} 122 | InventoryDate = (Get-Date) 123 | } 124 | 125 | } 126 | catch { 127 | Write-Error "[$Computer] - Unable to open Remote Registry" 128 | Continue 129 | } 130 | 131 | } 132 | catch { 133 | Write-Warning "[$Computer] - cannot be reached. $($_.Exception.Message)" 134 | } 135 | } 136 | } 137 | foreach ($Session in $PSSession) { 138 | _GetVMInfo -PSSession $Session 139 | } 140 | } 141 | End { 142 | if ($PSCmdlet.ParameterSetName -eq 'Computer' -AND $PSSession.count -gt 0) { 143 | Remove-PSSession $PSSession 144 | } 145 | } 146 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PSP-Inventory 2 | 3 | ![PowerShell Gallery](https://img.shields.io/powershellgallery/v/PSP-Inventory.svg?label=PSGallery%20Version&logo=PowerShell&style=flat-square) 4 | ![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/PSP-Inventory.svg?label=PSGallery%20Downloads&logo=PowerShell&style=flat-square) 5 | 6 | ## What does it do 7 | 8 | The PSP-Inventory module provides new cmdlets for you to inventorise your Windows environment. 9 | The following items are collected for you: 10 | 11 | - System Info [CPU/Mem etc] 12 | - Operating System Info 13 | - Disk Info 14 | - Network Info 15 | - Installed Software 16 | - Installed Security Updates 17 | - Installed Server Roles 18 | - Installed Certificates 19 | - Scheduled Tasks 20 | - Local Groups 21 | - Local Users 22 | 23 | The module has been created with a mindset to be able to quickly make an inventory of a new environment, providing default information required to get to know new systems. 24 | Seeing that I tend to work on a project basis a lot for different companies, getting inventory data really helps me with quickly evaluating the systems I need to work on. 25 | It might also simply help with keeping track of changes made on a system over time by re-running cmdlets and comparing the data collected. 26 | 27 | ![alt text](https://powershellpr0mpt.com/wp-content/uploads/2019/03/example1.png "Quickly collect all information required") 28 | 29 | ![alt text](https://powershellpr0mpt.com/wp-content/uploads/2019/03/example2.png "Objects are formatted for an easy on the eye display, but contain every bit of info you might require") 30 | 31 | ## Installing PSP-Inventory 32 | 33 | ```powershell 34 | # Install PSP-Inventory from the Powershell Gallery 35 | Find-Module PSP-Inventory | Install-Module 36 | ``` 37 | 38 | ### BREAKING CHANGES 39 | 40 | Do note that due to the release of v1.0.0 there might be breaking changes. 41 | This solves some of the issues the module was having, but might impact current users of the module. 42 | Be sure to check the [Change Log](CHANGELOG.md) for exact information on what has been changed. 43 | 44 | ### Change Log 45 | 46 | [Change Log can be viewed here](CHANGELOG.md) 47 | 48 | ### To Contribute 49 | 50 | [Please see the following article](CONTRIBUTING.md) 51 | 52 | ### License 53 | 54 | [License can be seen here](LICENSE.md) 55 | 56 | ### Known Issues 57 | 58 | - View the [Issues](https://github.com/powershellpr0mpt/PSP-Inventory/issues) list to see what's currently known. 59 | 60 | ### Examples 61 | 62 | Here are a few simple examples on how to use the module for basic inventory needs. 63 | 64 | All cmdlets currently already provide comment based help available within PowerShell itself, which can be found [here](https://github.com/powershellpr0mpt/PSP-Inventory/tree/master/PSP-Inventory/docs) 65 | 66 | #### Getting Network information 67 | 68 | ```powershell 69 | #Collect the list of computers to query 70 | $Computers = Get-Content 'C:\Temp\Computers.txt' 71 | Get-PspNicInfo -ComputerName $Computers -Drivers | Format-Table 72 | 73 | ComputerName Alias Index PhysicalAdapter IPAddress Status MacAddress DHCPEnabled DHCPServer DNSServers 74 | ------------ ----- ----- --------------- --------- ------ ---------- ----------- ---------- ---------- 75 | DC2012R2 Ethernet 10 True {192.168.14.3, fe80::e456:f730:f610:7eac} Connected 00:17:FB:00:00:00 False {127.0.0.1} 76 | SRV2012 Ethernet 10 True {192.168.14.5, fe80::2d7c:d6b8:d670:38df} Connected 00:17:FB:00:00:02 False {192.168.14.3} 77 | SRV2016CORE Ethernet 1 True {192.168.14.6, fe80::a438:7d49:4f12:b000} Connected 00:17:FB:00:00:03 False {192.168.14.3} 78 | SRV2019CORE Ethernet 1 True {192.168.14.7, fe80::31f3:d92a:a4b9:e3a8} Connected 00:17:FB:00:00:04 False {192.168.14.3} 79 | ``` 80 | 81 | #### Finding installed software and export it to Excel 82 | 83 | This depends on the availability of the [ImportExcel](https://github.com/dfinke/ImportExcel) module on your system 84 | 85 | ```powershell 86 | $Software = Get-PspSoftware -ComputerName NYC-DC01 87 | 88 | $Software | Export-Excel -Path "$Home\Inventory\Inventory.xlsx" -WorksheetName 'Software' -Append -AutoSize -AutoFilter -FreezeTopRowFirstColumn 89 | ``` 90 | 91 | This will provide you an Excel sheet work a worksheet named Software containing all the collected data. 92 | It will be automatically sized, filtered and the top row and first column will be frozen. 93 | 94 | If there's already data in this Excel sheet, it will automatically append the data to it instead of overwriting it. 95 | 96 | ### Compatibility 97 | 98 | #### Operating Systems 99 | 100 | This module has been tested on the following Windows Systems: 101 | 102 | Operating System | Tested | Expected to work 103 | ---|---|--- 104 | Windows 10 - 1809 | Yes | Yes 105 | Windows 10 - 1803 | Yes | Yes 106 | Windows 8.1 | No | Yes 107 | Windows 7 | No | Yes 108 | Windows Server 2019 | Yes | Yes 109 | Windows Server 2016 | Yes | Yes 110 | Windows Server 2012R2 | Yes | Yes 111 | Windows Server 2012 | Yes | Yes 112 | Windows Server 2008R2 | Yes | Yes 113 | Windows Server 2008 | Yes | Yes 114 | Windows Server 2003R2 | Yes | Yes 115 | 116 | It is not expected that this module will function on Unix/MacOS and they are not supported. 117 | 118 | #### PowerShell Versions 119 | 120 | This module has been tested with the following PowerShell versions: 121 | 122 | PowerShell Version | Tested 123 | --- | --- 124 | PowerShell 6 Core | Yes 125 | Windows PowerShell 5.1 | Yes 126 | Windows PowerShell 5 | Yes 127 | Windows PowerShell 4 | Yes 128 | Windows PowerShell 3 | Yes 129 | Windows PowerShell 2 | Yes -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | [cmdletbinding()] 2 | param( 3 | [ValidateSet('Default', 'Build', 'Analyze', 'Test', 'WinZip')] 4 | $Task = 'Default' 5 | ) 6 | 7 | Write-Host "Importing Modules:" -ForegroundColor Yellow 8 | $Modules = @('Psake', 'BuildHelpers', 'Pester', 'PSScriptAnalyzer', 'PSDeploy') 9 | 10 | 11 | ForEach ($Module in $Modules) { 12 | Write-Host "...$Module" -ForegroundColor Yellow 13 | try { 14 | $InstallModuleParams = @{ 15 | Name = $Module 16 | Scope = 'CurrentUser' 17 | Force = $true 18 | } 19 | if ($Module -eq 'Pester') { 20 | $InstallModuleParams.SkipPublisherCheck = $true 21 | } 22 | $null = Find-Module $Module -ErrorAction Stop 23 | $null = Install-Module @InstallModuleParams 24 | Write-Host "...Importing" -ForegroundColor Green 25 | Import-Module $Module 26 | Write-Host "...Complete" -ForegroundColor Green 27 | } 28 | catch { 29 | Write-Host "...Not Found!" -ForegroundColor Red 30 | Write-Error -Message $_ -ErrorAction Stop 31 | } 32 | } 33 | Write-Host "Completed Importing Modules`r`n" -ForegroundColor Green 34 | 35 | Push-Location $PSScriptRoot 36 | Write-Verbose "Cleaning current Build variables" 37 | Get-ChildItem -Path env:\bh* | Remove-Item 38 | Write-Verbose "Setting Build Variables" 39 | Set-BuildEnvironment 40 | 41 | Write-Host "Executing PSake Build`r`n" -ForegroundColor Green 42 | 43 | Invoke-Psake -buildFile .\psake.ps1 -properties $PSBoundParameters -noLogo -taskList $Task 44 | exit ( [int]( -not $psake.build_success ) ) 45 | -------------------------------------------------------------------------------- /psake.ps1: -------------------------------------------------------------------------------- 1 | # PSake makes variables declared here available in other scriptblocks 2 | # Init some things 3 | Properties { 4 | # Find the build folder based on build system 5 | $ProjectRoot = $env:BHProjectPath 6 | $ModuleName = $env:BHProjectName 7 | $ModuleVersion = (Get-Module -ListAvailable $env:BHPSModuleManifest).Version 8 | $TestsFolder = "$ProjectRoot\Tests" 9 | $TestsOutputFolder = "$ProjectRoot\_testresults\" 10 | $TestsOutput = "$TestsOutputFolder\Test_Help`_$TimeStamp.xml" 11 | $BuildFolder = "$ProjectRoot\_bin\$ModuleName" 12 | $VersionFolder = "$BuildFolder\$ModuleVersion" 13 | $ZipFolder = "$ProjectRoot\_zip" 14 | } 15 | 16 | Task default -Depends Build 17 | 18 | Task Build { 19 | Write-Host "Building Module Structure" -ForegroundColor Blue 20 | $FunctionsPublic = Get-ChildItem -Path $ProjectRoot\$ModuleName\Public -Recurse -Exclude *.Tests.* -File ` 21 | | ForEach-Object -Process {Get-Content -Path $_.FullName; "`r`n"} 22 | $FunctionsPrivate = Get-ChildItem -Path $ProjectRoot\$ModuleName\Private -Recurse -Exclude *.Tests.* -File ` 23 | | ForEach-Object -Process {Get-Content -Path $_.FullName; "`r`n"} 24 | 25 | If (-not (Test-Path $BuildFolder)) { 26 | Write-Host "Creating Build Folder" -ForegroundColor Blue 27 | $Null = New-Item -Path $BuildFolder -Type Directory -Force 28 | } Else { 29 | Write-Host "Clearing Existing Build Folder $BuildFolder" -ForegroundColor Blue 30 | Remove-Item -Path $BuildFolder/* -Recurse -Force 31 | } 32 | Write-Host "Creating Version Folder" -ForegroundColor Blue 33 | $Null = New-Item -Path $VersionFolder -Type Directory -Force 34 | 35 | If (-not (Test-Path $ZipFolder)) { 36 | Write-Host "Creating Zip Folder" -ForegroundColor Blue 37 | $Null = New-Item -Path $ZipFolder -Type Directory -Force 38 | } Else { 39 | Write-Host "Clearing Existing Zip Folder $ZipFolder" -ForegroundColor Blue 40 | Remove-Item -Path $ZipFolder/* -Recurse -Force 41 | } 42 | 43 | Write-Host "Copying Module Manifest" -ForegroundColor Blue 44 | $Null = Copy-Item -Path "$ProjectRoot\$ModuleName\" -Recurse -Destination $VersionFolder -Force 45 | 46 | Write-Host "Update the PSD1 FunctionsToExport for autoloading on build folder" -ForegroundColor Blue 47 | Set-ModuleFunctions -Name "$VersionFolder\$ModuleName" 48 | 49 | Write-Host "Update the PSD1 FormatsToExport for applying custom formats on cmdlets" -ForegroundColor Blue 50 | Set-ModuleFormats -Name "$VersionFolder\$ModuleName" -FormatsRelativePath '.\formats' 51 | 52 | Write-Host "Module built, verifying module output" -ForegroundColor Blue 53 | Get-Module -ListAvailable "$VersionFolder\$ModuleName\$ModuleName.psd1" | ForEach-Object -Process { 54 | $ExportedFunctions = $_ ` 55 | | Select-Object -Property @{ Name = "ExportedFunctions" ; Expression = { [string[]]$_.ExportedFunctions.Keys } } ` 56 | | Select-Object -ExpandProperty ExportedFunctions 57 | $ExportedAliases = $_ ` 58 | | Select-Object -Property @{ Name = "ExportedAliases" ; Expression = { [string[]]$_.ExportedAliases.Keys } } ` 59 | | Select-Object -ExpandProperty ExportedAliases 60 | $ExportedVariables = $_ ` 61 | | Select-Object -Property @{ Name = "ExportedVariables" ; Expression = { [string[]]$_.ExportedVariables.Keys } } ` 62 | | Select-Object -ExpandProperty ExportedVariables 63 | Write-Output "Name : $($_.Name)" 64 | Write-Output "Description : $($_.Description)" 65 | Write-Output "Guid : $($_.Guid)" 66 | Write-Output "Version : $($_.Version)" 67 | Write-Output "ModuleType : $($_.ModuleType)" 68 | Write-Output "ExportedFunctions : $ExportedFunctions" 69 | Write-Output "ExportedAliases : $ExportedAliases" 70 | Write-Output "ExportedVariables : $ExportedVariables" 71 | } 72 | } 73 | 74 | Task Analyze -Depends Build { 75 | $saResults = Invoke-ScriptAnalyzer -Path $VersionFolder\$ModuleName\$ModuleName.psm1 -Severity @('Error') -Recurse -Verbose:$false 76 | if ($saResults) { 77 | $saResults | Format-Table 78 | Write-Error -Message 'One or more Script Analyzer errors where found.' 79 | } 80 | } 81 | 82 | Task Test -Depends Analyze { 83 | If (-not (Test-Path $TestsOutputFolder)) { 84 | Write-Host "Creating Tests Output Folder" -ForegroundColor Blue 85 | $Null = New-Item -Path $TestsOutputFolder -Type Directory -Force 86 | } 87 | 88 | Write-Host "Removing Test Output > 5 runs ago" 89 | Get-ChildItem $TestsOutputFolder -Recurse | Where-Object {-not $_.PSIsContainer} | Sort-Object CreationTime -Descending | Select-Object -Skip 5 | Remove-Item -Force 90 | 91 | Write-Host "Testing Module" -ForegroundColor Blue 92 | $HelpResults = Invoke-Pester $TestsFolder -OutputFormat NUnitXml -OutputFile $TestsOutput -PassThru 93 | If ($HelpResults.FailedCount -gt 0) { 94 | Exit $HelpResults.FailedCount 95 | } 96 | } 97 | 98 | Task WinZip -depends Test { 99 | $FileName = "$ZipFolder\$ModuleName.$ModuleVersion.zip" 100 | Compress-Archive -Path "$VersionFolder\$ModuleName\" -DestinationPath $FileName -Force 101 | } -------------------------------------------------------------------------------- /tests/External.Help.Tests.ps1: -------------------------------------------------------------------------------- 1 | Write-Host "Using BuildHelpers Variables" -ForegroundColor Yellow 2 | # build vars 3 | $ProjectRoot = $env:BHProjectPath 4 | $ModuleName = $env:BHProjectName 5 | $ModuleVersion = (Get-Module -ListAvailable $env:BHPSModuleManifest).Version 6 | $BuildFolder = "$ProjectRoot\_bin\$ModuleName" 7 | $VersionFolder = "$BuildFolder\$ModuleVersion\$ModuleName" 8 | ## testing vars 9 | $ModuleManifestName = "$ModuleName.psd1" 10 | $ModulePath = "$VersionFolder\$ModuleManifestName" 11 | 12 | Get-Module $ModuleName | Remove-Module 13 | 14 | Import-Module $ModulePath -Force 15 | 16 | Describe -Name 'Check external help' { 17 | $cmds = Get-Command -Module $ModuleName 18 | foreach ($cmdlet in $cmds){ 19 | $help = Get-Help $cmdlet 20 | It "$cmdlet has external help defined" { 21 | $help.Description | Should -Not -BeNullOrEmpty 22 | } 23 | It "$cmdlet has at least one example defined" { 24 | $help.Examples | Should -Not -BeNullOrEmpty 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /tests/Module.Help.ps1: -------------------------------------------------------------------------------- 1 | 2 | <# 3 | .SYNOPSIS 4 | Tests the PowerShell help for the commands in a module. 5 | 6 | .DESCRIPTION 7 | This Pester test verifies that the commands in a module have basic help content. 8 | It works on all command types and both comment-based and XML help. 9 | 10 | This test verifies that Get-Help is not autogenerating help because it cannot 11 | find any help for the command. Then, it checks for the following help elements: 12 | - Synopsis 13 | - Description 14 | - Parameter: 15 | - A description of each parameter. 16 | - An accurate value for the Mandatory property. 17 | - An accurate value for the .NET type of the parameter value. 18 | - No extra parameters: 19 | - Verifies that there are no parameters in help that are not also in the code. 20 | 21 | When testing attributes of parameters that appear in multiple parameter sets, 22 | this test uses the parameter that appears in the default parameter set, if one 23 | is defined. 24 | 25 | You can run this Tests file from any location. For a help test that is located in a module 26 | directory, use https://github.com/juneb/PesterTDD/InModule.Help.Tests.ps1 27 | 28 | .PARAMETER ModuleName 29 | Enter the name of the module to test. You can enter only one name at a time. This 30 | parameter is mandatory. 31 | 32 | .PARAMETER RequiredVersion 33 | Enter the version of the module to test. This parameter is optional. If you 34 | omit it, the test runs on the latest version of the module in $env:PSModulePath. 35 | 36 | .EXAMPLE 37 | .\Module.Help.Tests.ps1 -ModuleName Pester -RequiredVersion 3.4.0 38 | This command runs the tests on the commands in Pester 3.4.0. 39 | 40 | .EXAMPLE 41 | .\Module.Help.Tests.ps1 -ModuleName Pester 42 | This command runs the tests on the commands in latest local version of the 43 | Pester module. 44 | 45 | 46 | .NOTES 47 | =========================================================================== 48 | Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.119 49 | Created on: 4/12/2016 1:11 AM 50 | Created by: June Blender 51 | Organization: SAPIEN Technologies, Inc 52 | Filename: *.Help.Tests.ps1 53 | =========================================================================== 54 | #> 55 | 56 | Write-Host "Using BuildHelpers Variables" -ForegroundColor Yellow 57 | # build vars 58 | $ProjectRoot = $env:BHProjectPath 59 | $ModuleName = $env:BHProjectName 60 | $ModuleVersion = (Get-Module -ListAvailable $env:BHPSModuleManifest).Version 61 | $BuildFolder = "$ProjectRoot\_bin\$ModuleName" 62 | $VersionFolder = "$BuildFolder\$ModuleVersion\$ModuleName" 63 | ## testing vars 64 | $ModuleManifestName = "$ModuleName.psd1" 65 | $ModulePath = "$VersionFolder\$ModuleManifestName" 66 | 67 | # Remove all versions of the module from the session. Pester can't handle multiple versions. 68 | Get-Module $ModuleName | Remove-Module 69 | 70 | #Requires -Module @{ModuleName = 'Pester'; ModuleVersion = '3.4.0'} 71 | 72 | <# 73 | .SYNOPSIS 74 | Gets command parameters; one per name. Prefers default parameter set. 75 | 76 | .DESCRIPTION 77 | Gets one CommandParameterInfo object for each parameter in the specified 78 | command. If a command has more than one parameter with the same name, this 79 | function gets the parameters in the default parameter set, if one is specified. 80 | 81 | For example, if a command has two parameter sets: 82 | Name, ID (default) 83 | Name, Path 84 | This function returns: 85 | Name (default), ID Path 86 | 87 | This function is used to get parameters for help and for help testing. 88 | 89 | .PARAMETER Command 90 | Enter a CommandInfo object, such as the object that Get-Command returns. You 91 | can also pipe a CommandInfo object to the function. 92 | 93 | This parameter takes a CommandInfo object, instead of a command name, so 94 | you can use the parameters of Get-Command to specify the module and version 95 | of the command. 96 | 97 | .EXAMPLE 98 | PS C:\> Get-ParametersDefaultFirst -Command (Get-Command New-Guid) 99 | This command uses the Command parameter to specify the command to 100 | Get-ParametersDefaultFirst 101 | 102 | .EXAMPLE 103 | PS C:\> Get-Command New-Guid | Get-ParametersDefaultFirst 104 | You can also pipe a CommandInfo object to Get-ParametersDefaultFirst 105 | 106 | .EXAMPLE 107 | PS C:\> Get-ParametersDefaultFirst -Command (Get-Command BetterCredentials\Get-Credential) 108 | You can use the Command parameter to specify the CommandInfo object. This 109 | command runs Get-Command module-qualified name value. 110 | 111 | .EXAMPLE 112 | PS C:\> $ModuleSpec = @{ModuleName='BetterCredentials';RequiredVersion=4.3} 113 | PS C:\> Get-Command -FullyQualifiedName $ModuleSpec | Get-ParametersDefaultFirst 114 | This command uses a Microsoft.PowerShell.Commands.ModuleSpecification object to 115 | specify the module and version. You can also use it to specify the module GUID. 116 | Then, it pipes the CommandInfo object to Get-ParametersDefaultFirst. 117 | #> 118 | function Get-ParametersDefaultFirst { 119 | Param 120 | ( 121 | [Parameter(Mandatory = $true, 122 | ValueFromPipeline = $true)] 123 | [System.Management.Automation.CommandInfo] 124 | $Command 125 | ) 126 | 127 | BEGIN { 128 | $Common = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable' 129 | $parameters = @() 130 | } 131 | PROCESS { 132 | if ($defaultPSetName = $Command.DefaultParameterSet) { 133 | $defaultParameters = ($Command.ParameterSets | Where-Object Name -eq $defaultPSetName).parameters | Where-Object Name -NotIn $common 134 | $otherParameters = ($Command.ParameterSets | Where-Object Name -ne $defaultPSetName).parameters | Where-Object Name -NotIn $common 135 | 136 | $parameters += $defaultParameters 137 | if ($parameters -and $otherParameters) { 138 | $otherParameters | ForEach-Object { 139 | if ($_.Name -notin $parameters.Name) { 140 | $parameters += $_ 141 | } 142 | } 143 | $parameters = $parameters | Sort-Object Name 144 | } 145 | } 146 | else { 147 | $parameters = $Command.ParameterSets.Parameters | Where-Object Name -NotIn $common | Sort-Object Name -Unique 148 | } 149 | 150 | 151 | return $parameters 152 | } 153 | END { } 154 | } 155 | 156 | <# 157 | .SYNOPSIS 158 | Gets the module/snapin name and version for a command. 159 | 160 | .DESCRIPTION 161 | This function takes a CommandInfo object (the type that 162 | Get-Command returns) and retuns a custom object with the 163 | following properties: 164 | 165 | -- [string] $CommandName 166 | -- [string] $ModuleName (or PSSnapin name) 167 | -- [string] $ModuleVersion (or PowerShell Version) 168 | 169 | .PARAMETER CommandInfo 170 | Specifies a Commandinfo object, e.g. (Get-Command Get-Item). 171 | 172 | .EXAMPLE 173 | PS C:\> Get-CommandVersion -CommandInfo (Get-Command Get-Help) 174 | 175 | CommandName ModuleName Version 176 | ----------- ---------- ------- 177 | Get-Help Microsoft.PowerShell.Core 3.0.0.0 178 | 179 | This command gets information about a cmdlet in a PSSnapin. 180 | 181 | 182 | .EXAMPLE 183 | PS C:\> Get-CommandVersion -CommandInfo (Get-Command New-JobTrigger) 184 | 185 | CommandName ModuleName Version 186 | ----------- ---------- ------- 187 | New-JobTrigger PSScheduledJob 1.1.0.0 188 | 189 | This command gets information about a cmdlet in a module. 190 | #> 191 | function Get-CommandVersion { 192 | Param 193 | ( 194 | [Parameter(Mandatory = $true)] 195 | [System.Management.Automation.CommandInfo] 196 | $CommandInfo 197 | ) 198 | 199 | if ((-not ((($commandModuleName = $CommandInfo.Module.Name) -and ($commandVersion = $CommandInfo.Module.Version)) -or 200 | (($commandModuleName = $CommandInfo.PSSnapin) -and ($commandVersion = $CommandInfo.PSSnapin.Version))))) { 201 | Write-Error "For $($CommandInfo.Name) : Can't find PSSnapin/module name and version" 202 | } 203 | else { 204 | # "For $commandName : Module is $commandModuleName. Version is $commandVersion" 205 | [PSCustomObject]@{ CommandName = $CommandInfo.Name; ModuleName = $commandModuleName; Version = $commandVersion } 206 | } 207 | } 208 | 209 | 210 | # Import the required version 211 | Import-Module $ModulePath -Force 212 | 213 | $ms = [Microsoft.PowerShell.Commands.ModuleSpecification]@{ ModuleName = $ModuleName; RequiredVersion = $ModuleVersion } 214 | $commands = Get-Command -FullyQualifiedModule $ms -CommandType Cmdlet, Function, Workflow # Not alias 215 | 216 | ## When testing help, remember that help is cached at the beginning of each session. 217 | ## To test, restart session. 218 | 219 | foreach ($command in $commands) { 220 | $commandName = $command.Name 221 | 222 | # Get the module name and version of the command. Used in the Describe name. 223 | $commandModuleVersion = Get-CommandVersion -CommandInfo $command 224 | 225 | # The module-qualified command fails on Microsoft.PowerShell.Archive cmdlets 226 | $Help = Get-Help $ModuleName\$commandName -ErrorAction SilentlyContinue 227 | if ($Help.Synopsis -like '*`[``]*') { 228 | $Help = Get-Help $commandName -ErrorAction SilentlyContinue 229 | } 230 | 231 | Describe "Test help for $commandName in $($commandModuleVersion.ModuleName) ($($commandModuleVersion.Version))" { 232 | 233 | # If help is not found, synopsis in auto-generated help is the syntax diagram 234 | It "should not be auto-generated" { 235 | $Help.Synopsis | Should Not BeLike '*`[``]*' 236 | } 237 | 238 | # Should be a synopsis for every function 239 | It "gets synopsis for $commandName" { 240 | $Help.Synopsis | Should Not beNullOrEmpty 241 | } 242 | 243 | # Should be a description for every function 244 | It "gets description for $commandName" { 245 | $Help.Description | Should Not BeNullOrEmpty 246 | } 247 | 248 | # Should be at least one example 249 | It "gets example code from $commandName" { 250 | ($Help.Examples.Example | Select-Object -First 1).Code | Should Not BeNullOrEmpty 251 | } 252 | 253 | # Should be at least one example description 254 | It "gets example help from $commandName" { 255 | ($Help.Examples.Example.Remarks | Select-Object -First 1).Text | Should Not BeNullOrEmpty 256 | } 257 | 258 | Context "Test parameter help for $commandName" { 259 | 260 | # $Common = 'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable', 'OutBuffer', 'OutVariable', 261 | 'PipelineVariable', 'Verbose', 'WarningAction', 'WarningVariable' 262 | 263 | # Get parameters. When >1 parameter with same name, 264 | # get parameter from the default parameter set, if any. 265 | $parameters = Get-ParametersDefaultFirst -Command $command 266 | 267 | $parameterNames = $parameters.Name 268 | $HelpParameterNames = $Help.Parameters.Parameter.Name | Sort-Object -Unique 269 | 270 | foreach ($parameter in $parameters) { 271 | $parameterName = $parameter.Name 272 | $parameterHelp = $Help.parameters.parameter | Where-Object Name -EQ $parameterName 273 | 274 | # Should be a description for every parameter 275 | It "gets help for parameter: $parameterName : in $commandName" { 276 | $parameterHelp.Description.Text | Should Not BeNullOrEmpty 277 | } 278 | 279 | # Required value in Help should match IsMandatory property of parameter 280 | It "help for $parameterName parameter in $commandName has correct Mandatory value" { 281 | $codeMandatory = $parameter.IsMandatory.toString() 282 | $parameterHelp.Required | Should Be $codeMandatory 283 | } 284 | 285 | # Parameter type in Help should match code 286 | It "help for $commandName has correct parameter type for $parameterName" { 287 | $codeType = $parameter.ParameterType.Name 288 | # To avoid calling Trim method on a null object. 289 | $helpType = if ($parameterHelp.parameterValue) { $parameterHelp.parameterValue.Trim() } 290 | $helpType | Should be $codeType 291 | } 292 | } 293 | 294 | foreach ($helpParm in $HelpParameterNames) { 295 | # Shouldn't find extra parameters in help. 296 | It "finds help parameter in code: $helpParm" { 297 | $helpParm -in $parameterNames | Should Be $true 298 | } 299 | } 300 | } 301 | } 302 | } -------------------------------------------------------------------------------- /tests/UnitTests.Tests.ps1: -------------------------------------------------------------------------------- 1 | Write-Host "Using BuildHelpers Variables" -ForegroundColor Yellow 2 | # build vars 3 | $ProjectRoot = $env:BHProjectPath 4 | $ModuleName = $env:BHProjectName 5 | $ModuleVersion = (Get-Module -ListAvailable $env:BHPSModuleManifest).Version 6 | $BuildFolder = "$ProjectRoot\_bin\$ModuleName" 7 | $VersionFolder = "$BuildFolder\$ModuleVersion\$ModuleName" 8 | ## testing vars 9 | $ModuleManifestName = "$ModuleName.psd1" 10 | $ModulePath = "$VersionFolder\$ModuleManifestName" 11 | 12 | Get-Module $ModuleName | Remove-Module 13 | 14 | Import-Module $ModulePath -Force 15 | 16 | Describe 'Module Manifest Test' { 17 | It 'Passes Test-ModuleManifest' { 18 | Test-ModuleManifest -Path $ModulePath | Should Be $true 19 | } 20 | } 21 | 22 | Describe 'Module Imported Test' { 23 | It 'Confirms Module Is Loaded' { 24 | (Get-Module $ModuleName) -eq $null | Should Be $false 25 | } 26 | } --------------------------------------------------------------------------------