Giter VIP home page Giter VIP logo

metadata's Introduction

PoshCode Package Manager Module (BETA)

PoshCode's purpose is to make it easier to distribute PowerShell modules and scripts over the internet or within local and corporate networks.

With this new project we are focusing on making it easy to distribute modules without explaining module installation to your users.

Additionally, we're supporting the automatic installation of dependencies, so that you can distribute modules which have a dependency on other modules without having to worry about how your users will find and install them.

The module has two main commands for users, and a third for module developers:

  1. Find-Module searches configured module registries and repositories
  2. Install-Module installs modules from local packages (.nupkg or .zip files), or from URLs or UNC paths
  3. Compress-Module creates a redistributable module package from a module on your system

To install the PoshCode module

If your "WebClient" service is running (this is Window's built-in WebDAV client), you can install it straight from our server with a single command in any version of PowerShell:

    \\PoshCode.org\DavWWWRoot\Modules\Install.ps1

If you have problems with that (various things can make Windows WebDAV slow, and the service doesn't seem to be installed by default on server OSes), you will need to download and run our Install.ps1 script. Of course, you can still do that from PowerShell:

On PowerShell 3 and up you can do that using Invoke-WebRequest:

    # First download, then run, then delete the installer:
    iwr http://PoshCode.org/i -OutF PC.ps1; .\PC; rm .\PC.ps1

On PowerShell 2 you need to create and use a WebClient:

    (New-Object System.Net.WebClient).DownloadFile("http://poshcode.org/i","$pwd\pc.ps1"); .\PC; rm .\PC.ps1

The rest of the documentation will be in the wiki, broken into several sections:

  1. Installing Modules (user's guide)
  2. Creating Module Packages
  3. Distributing Module Packages (should include the "how to" for enterprise users)
  4. Additional Features of PoshCode (everything else)

Note: the additional features of PoshCode include coverages of some of the mini modules I wrote to support the Package Manager functionality, mostly around Serialization and Configuration.

metadata's People

Contributors

ajhall avatar bravo-kernel avatar fsackur avatar indented-automation avatar jaykul avatar lipkau avatar ramblingcookiemonster avatar scrthq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

metadata's Issues

Some objects can't be serialized out of the box

When trying to export properties from my Win 10 BitLocker setup, ConvertTo-Metdata fails to convert the datastructure.

$OsBitLockerVolume = Get-BitLockerVolume | where VolumeType -eq OperatingSystem

$OsBitLockerVolume.KeyProtector

KeyProtectorId      : {XXXX}
AutoUnlockProtector :
KeyProtectorType    : RecoveryPassword
KeyFileName         :
RecoveryPassword    : XXXX
KeyCertificateType  :
Thumbprint          :

KeyProtectorId      : {XXXX}
AutoUnlockProtector :
KeyProtectorType    : TpmPin
KeyFileName         :
RecoveryPassword    :
KeyCertificateType  :
Thumbprint          :
$OsBitLockerVolume = Get-BitLockerVolume | where VolumeType -eq OperatingSystem

$OsBitLockerVolume.KeyProtector | ConvertTo-Metadata

WARNING: Microsoft.BitLocker.Structures.BitLockerVolumeKeyProtector is not serializable. Serializing as string
'RecoveryPassword'
WARNING: Microsoft.BitLocker.Structures.BitLockerVolumeKeyProtector is not serializable. Serializing as string
'TpmPin'

where as, ConvertTo-Json will succeed.

$OsBitLockerVolume.KeyProtector | ConvertTo-Json

[
    {
        "KeyProtectorId":  "{XXXX}",
        "AutoUnlockProtector":  null,
        "KeyProtectorType":  3,
        "KeyFileName":  "",
        "RecoveryPassword":  "XXXX",
        "KeyCertificateType":  null,
        "Thumbprint":  ""
    },
    {
        "KeyProtectorId":  "{XXXX}",
        "AutoUnlockProtector":  null,
        "KeyProtectorType":  4,
        "KeyFileName":  "",
        "RecoveryPassword":  "",
        "KeyCertificateType":  null,
        "Thumbprint":  ""
    }
]

Metadata not usable with boolean values

With the latest version of this code (looks like it was recently refactored out of Configuration) a metadata value that's set to $true or $false doesn't get propagated correctly. This is causing Build-Module to behave unexpectedly.

Use case: Invoke Build-Module with inputs coming from a metadata file.
Expected: Builder places output in a version directory (e.g. /wherever/MyModule/1.2.3).
Observed: Builder does not find a value for VersionedOutputDirectory and ultimately does not place output in a version directory (output goes to /wherever/MyModule).

Metadata file contents:

@{
	Path = "MyModule.psd1"
	OutputDirectory = "..\bin\MyModule"
	SourceDirectories = 'Classes','Private','Public'
	PublicFilter = 'Public\*.ps1'
	VersionedOutputDirectory = $true
}

Output from Build-Module -Debug:

DEBUG: ConvertFrom-Metadata: Replaced true in metadata: @{
 Path = "EmsAutomatedTests.psd1"
 OutputDirectory = "..\bin\EmsAutomatedTests"
 SourceDirectories = 'Classes','Private','Public'
 PublicFilter = 'Public\*.ps1'
 VersionedOutputDirectory = ${__Metadata__true__}
 CopyPaths = "Resources"
}
[...snip...]
DEBUG: ConvertFrom-Metadata: Setting __Metadata__PSScriptRoot__ = D:\a\1\s\EmsAutomatedTests\Source
DEBUG: ConvertFrom-Metadata: Setting __Metadata__ScriptRoot__ = D:\a\1\s\EmsAutomatedTests\Source
DEBUG: ConvertFrom-Metadata: Setting __Metadata__PoshCodeModuleRoot__ = D:\a\1\s\EmsAutomatedTests\Source
DEBUG:   Parameter: SourcePath
DEBUG:     ... Update BuildInfo[SourcePath] from Path
DEBUG:     From Manifest: EmsAutomatedTests.psd1
DEBUG:   Parameter: OutputDirectory
DEBUG:     From Manifest: ..\bin\EmsAutomatedTests
DEBUG:   Parameter: VersionedOutputDirectory
DEBUG:   Parameter: UnversionedOutputDirectory
DEBUG:   Parameter: SemVer
DEBUG:   Parameter: Version
DEBUG:   Parameter: Prerelease
DEBUG:   Parameter: BuildMetadata
DEBUG:   Parameter: CopyPaths
DEBUG:     From Manifest: Resources
DEBUG:   Parameter: SourceDirectories
DEBUG:     From Manifest: Classes, Private, Public
DEBUG:   Parameter: PublicFilter
DEBUG:     From Manifest: Public\*.ps1
DEBUG:   Parameter: IgnoreAliasAttribute
DEBUG:   Parameter: Encoding
DEBUG:     From Default: UTF8
DEBUG:   Parameter: Prefix
DEBUG:   Parameter: Suffix
DEBUG:   Parameter: Target
DEBUG:     From Default: CleanBuild
DEBUG:   Parameter: Passthru
DEBUG: Finished parsing Build Manifest

This seems related to the following code, but I could be mistaken:

# Set the __Metadata__ValidVariables__ in our scope but not for constant variables:

Square Bracket Indexing breaks PSCustomObject serialization

#1 8b5e3c4 breaks PSCustomObject serialization.

Expected PSObject property values are intact when serialized.
Actual PSObject property values are all empty strings when serialized.

# requires -Modules Metadata
$PSVersionTable | Select-Object *
Get-Module -Name Metadata
Get-ChildItem -File | Select-Object FullName, *Utc, Length | ConvertTo-Metadata

# Results....
#
# SerializationVersion      : 1.1.0.1
# WSManStackVersion         : 3.0
# PSCompatibleVersions      : {1.0, 2.0, 3.0, 4.0…}
# GitCommitId               : 7.2.0
# OS                        : Microsoft Windows 10.0.19043
# Platform                  : Win32NT
# PSEdition                 : Core
# PSVersion                 : 7.2.0
# PSRemotingProtocolVersion : 2.3
#
# ModuleType Version    PreRelease Name                                ExportedCommands
# ---------- -------    ---------- ----                                ----------------
# Script     1.5.1                 Metadata                            {Add-MetadataConverter, ConvertFrom-Metadata, ConvertTo-Metadata, Export-Metadata…}
#
# (PSObject @{
#   CreationTimeUtc = ""
#   FullName = ""
#   LastAccessTimeUtc = ""
#   LastWriteTimeUtc = ""
#   Length = ""
# } -TypeName 'Selected.System.IO.FileInfo','System.Management.Automation.PSCustomObject','System.Object')
# (PSObject @{
#   CreationTimeUtc = ""
#   FullName = ""
#   LastAccessTimeUtc = ""
#   LastWriteTimeUtc = ""
#   Length = ""
# } -TypeName 'Selected.System.IO.FileInfo','System.Management.Automation.PSCustomObject','System.Object')
# (PSObject @{
#   CreationTimeUtc = ""
#   FullName = ""
#   LastAccessTimeUtc = ""
#   LastWriteTimeUtc = ""
#   Length = ""
# } -TypeName 'Selected.System.IO.FileInfo','System.Management.Automation.PSCustomObject','System.Object')

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.