Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Microsoft.Windows.Assertion Module #90

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ uilt
Windo
ELSPROBLEMS
requ
PDevice
whatif
pscustomobject
VGpu
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/spelling/expect/generic_terms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ ssh
usr
versioning
VGpu
pnp
RTX
ADDLOCAL
9 changes: 9 additions & 0 deletions pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ extends:
displayName: 'Publish Pipeline Microsoft.DotNet.Dsc'
targetPath: $(Build.SourcesDirectory)\resources\Microsoft.DotNet.Dsc\
artifactName: Microsoft.DotNet.Dsc
- output: pipelineArtifact
displayName: 'Publish Pipeline Microsoft.Windows.Assertion'
targetPath: $(Build.SourcesDirectory)\resources\Microsoft.Windows.Assertion\
artifactName: Microsoft.Windows.Assertion"

steps:
- checkout: self
Expand All @@ -92,6 +96,11 @@ extends:
pwsh: true
targetType: 'inline'
script: |
$InstalledPesterModules = (Get-Module -ListAvailable -Name Pester)
if ($InstalledPesterModules -and $InstalledPesterModules[0].Version -lt [System.Version]::Parse('5.6.1')) {
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name Pester -RequiredVersion 5.6.1 -Force -SkipPublisherCheck
}
$env:PSModulePath += ";$(Build.SourcesDirectory)\resources"
Invoke-Pester -CI
workingDirectory: $(Build.SourcesDirectory)\tests\
Expand Down
71 changes: 71 additions & 0 deletions resources/Help/Microsoft.Windows.Assertion/PnPDevice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
external help file: Microsoft.Windows.Assertion.psm1-Help.xml
Module Name: Microsoft.Windows.Assertion
ms.date: 11/2/2024
online version:
schema: 2.0.0
title: PnPDevice
---

# PnPDevice

## SYNOPSIS

Ensures at least one PnP Device is connected which matches the required parameters

## DESCRIPTION

The `PnPDevice` DSC Resource allows you to check for specific PnP Devices on the system as a pre-requisite for invoking other DSC Resources. This resource does not have the capability to modify PnP Device information.

## PARAMETERS

**Parameter**|**Attribute**|**DataType**|**Description**|**Allowed Values**
:-----|:-----|:-----|:-----|:-----
`FriendlyName`|Optional|String[]|The name of the PnP Device to be found|--
`DeviceClass`|Optional|String[]|The PnP Class of the PnP Device to be found.| For example: `Display` or `Keyboard` or `PrintQueue`
`Status`|Optional|String[]|The current status of the PnP Device to be found|`OK`, `ERROR`, `DEGRADED`, `UNKNOWN`

## EXAMPLES

### Example 1

```powershell
# Check that a device with a specific name is connected
$params = @{
FriendlyName = 'NVIDIA RTX A1000 Laptop GPU'
}
Invoke-DscResource -Name PnPDevice -Method Test -Property $params -ModuleName Microsoft.Windows.Assertion
```

### EXAMPLE 2

```powershell
# Check that any PnP Device is in the error state
$params = @{
Status = 'ERROR'
}
Invoke-DscResource -Name PnPDevice -Method Test -Property $params -ModuleName Microsoft.Windows.Assertion
```

### EXAMPLE 3

```powershell
# Check that any Keyboard or Mouse is in the error state
$params = @{
DeviceClass = @('Keyboard'; 'Mouse')
Status = 'ERROR'
}
Invoke-DscResource -Name PnPDevice -Method Test -Property $params -ModuleName Microsoft.Windows.Assertion
```

### EXAMPLE 4

```powershell
# Check that a specific device is operational
$params = @{
FriendlyName = 'Follow-You-Printing'
DeviceClass = 'PrintQueue'
Status = 'OK'
}
Invoke-DscResource -Name PnPDevice -Method Test -Property $params -ModuleName Microsoft.Windows.Assertion
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
@{
RootModule = 'Microsoft.Windows.Assertion.psm1'
ModuleVersion = '0.1.0'
GUID = 'e3510ba2-cc19-4fb2-872a-a40833c30e58'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Copyright = '(c) Microsoft Corp. All rights reserved.'
Description = 'DSC Module for ensuring the system meets certain specifications'
PowerShellVersion = '7.2'
DscResourcesToExport = @(
'OsEditionId',
'SystemArchitecture',
'ProcessorArchitecture',
'HyperVisor',
'OsInstallDate',
'OsVersion',
'CsManufacturer',
'CsModel',
'CsDomain',
'PowerShellVersion',
'PnPDevice'
)
PrivateData = @{
PSData = @{
# A URL to the license for this module.
LicenseUri = 'https://github.com/microsoft/winget-dsc#MIT-1-ov-file'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/microsoft/winget-dsc'

# Tags applied to this module. These help with module discovery in online galleries.
Trenly marked this conversation as resolved.
Show resolved Hide resolved
Tags = @(
'PSDscResource_OsEditionId',
'PSDscResource_SystemArchitecture',
'PSDscResource_ProcessorArchitecture',
'PSDscResource_HyperVisor',
'PSDscResource_OsInstallDate',
'PSDscResource_OsVersion',
'PSDscResource_CsManufacturer',
'PSDscResource_CsModel',
'PSDscResource_CsDomain',
'PSDscResource_PowerShellVersion',
'PSDscResource_PnPDevice'
)

# Prerelease string of this module
Prerelease = 'alpha'
}
}
}
Loading
Loading