Coder Social home page Coder Social logo

wac's Introduction

https://stackoverflow.com/questions/68992255/why-cant-export-variable-members-in-a-powershell-module-using-variablestoexport

https://powershellexplained.com/2016-11-06-powershell-hashtable-everything-you-wanted-to-know-about/#using-the-brackets-for-access https://powershellexplained.com/2016-10-28-powershell-everything-you-wanted-to-know-about-pscustomobject/

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.4

https://www.red-gate.com/simple-talk/sysadmin/powershell/powershell-time-saver-automatic-defaults/

// Check for PS modules updates

Get-InstalledModule | ForEach-Object {
    $installedModule = $_
    # Determine if the installed module is a prerelease
    $isPrerelease = $installedModule.Version -match '-'
    $findModuleParams = @{
        Name = $installedModule.Name
    }
    if ($isPrerelease) {
        $findModuleParams['AllowPrerelease'] = $true
    }

    $latestModule = Find-Module @findModuleParams

    # Use version comparison that accounts for prerelease
    $installedVersion = $installedModule.Version
    $latestVersion = $latestModule.Version

    # Only proceed if there's a version difference, considering prerelease status
    if ($isPrerelease -or ($installedVersion -ne $latestVersion)) {
        # Further check to ensure we're only reporting genuine updates
        if (-not $isPrerelease -or ($isPrerelease -and $installedVersion -ne $latestVersion)) {
            [PSCustomObject]@{
                ModuleName = $installedModule.Name
                InstalledVersion = $installedModule.Version
                LatestVersion = $latestModule.Version
            }
        }
    }
} | Where-Object { $_ } | Format-Table -AutoSize

// Update PS module

Update-Module -Name ModuleName

// List PS modules

$env:PSModulePath -split ';' | ForEach-Object {
    if (Test-Path $_) {
        Write-Host "=================================================="
        Write-Host "Modules in path: $_"
        Write-Host "=================================================="
        Get-ChildItem -Path $_ -Directory | ForEach-Object { " - $($_.Name)" }
    }
}

// Use WAC Get-DscConfigurationState -YamlFilePath C:\Projets\WaC\DSCv2\ressources.yaml Test-DscConfigurationState -YamlFilePath C:\Projets\WaC\DSCv2\ressources.yaml Compare-DscConfigurationState -YamlFilePath C:\Projets\WaC\DSCv2\ressources.yaml -Report -JsonDiff Set-DscConfigurationState -YamlFilePath C:\Projets\WaC\DSCv2\ressources.yaml -Report

// Prérequis ??? Set-PSRepository PSGallery -InstallationPolicy Trusted Install-Module powershell-yaml Install-Module PSDscResources -Repository PSGallery Install-Module PSDesiredStateConfiguration -Repository PSGallery Install-Module Microsoft.WinGet.DSC -AllowPrerelease Install-Module Microsoft.VisualStudio.DSC

Déposer les modules dans [Environment]::GetFolderPath("MyDocuments") -> \PowerShell\Modules winget install -e -h --accept-package-agreements --accept-source-agreements --id Microsoft.PowerShell

wac's People

Contributors

guylescalier avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.