[玩转系统] PowerShell 模块布局的乐趣
作者:精品下载站 日期:2024-12-14 08:05:07 浏览:14 分类:玩电脑
PowerShell 模块布局的乐趣
当我一直致力于我的新 PowerShell 项目(我在最近的帖子中讨论过该项目)时,我不断“发现”有趣的脚本编写机会。今天我想分享一些我编写的代码,这些代码可以更轻松地构建 PowerShell 模块目录结构。有大量现有工具和脚本可用于构建项目或目录结构。例如像石膏这样的项目。我绝不是推荐我的功能而不是这些工具。但也许它们可能会填补一个空白,为您自己的工作激发灵感,或者教您一些有关 PowerShell 的新知识。
模型模块
我首先创建一个示例模块目录文件夹。这是我最近在编写新的 PowerShell 模块时倾向于使用的文件夹布局。我还将创建一些简单的文本文件,例如自述文件、更改日志和许可证文件。无需创建模块 psm1 文件或清单。这是一项单独且具体的任务。我现在定义的是一个通用模型。
顺便说一句,Show-Tree 来自 PSScriptTools 模块。
出口
出口流程相对简单。我需要递归浏览列出目录和文件的文件夹。因为我可能有嵌套目录,所以我需要捕获相对路径。
为了简化相对路径,我需要将位置设置为根目录。因为我知道我最终将重新创建此结构,所以我需要能够区分目录和文件。我还需要捕获文件内容。
Get-ChildItem -Recurse |
ForEach-Object {
$relPath = (Resolve-Path -Path $_.fullname -Relative) -replace "\.\", ""
Write-Verbose "Processing $relPath"
if ($_.Gettype().name -eq 'FileInfo') {
$f = [pscustomobject]@{
ItemType = "file"
Path = $relPath
Content = (Get-Content -Path $_.fullname)
}
$out.add($f)
}
else {
$d = [pscustomobject]@{
ItemType = "directory"
Path = $relPath
}
$out.Add($d)
}
} #foreach-object
在我的代码中,我将前导 .\ 剥离到相对路径。然后,我为每个项目类型创建一个自定义对象。每个对象都会添加到 $out 列表中。然后该列表将转换为 json 并保存到文件中。
$out | ConvertTo-Json | Out-File -FilePath $FilePath
该命令创建了此 json 内容。
[
{
"Created": "12/16/2021 10:44 AM",
"CreatedBy": "Jeff",
"Computername": "THINKP1",
"Source": "C:\work\sample",
"Version": "1.0"
},
{
"ItemType": "directory",
"Path": ".github"
},
{
"ItemType": "directory",
"Path": ".vscode"
},
{
"ItemType": "directory",
"Path": "docs"
},
{
"ItemType": "directory",
"Path": "en-us"
},
{
"ItemType": "directory",
"Path": "formats"
},
{
"ItemType": "directory",
"Path": "functions"
},
{
"ItemType": "directory",
"Path": "icons"
},
{
"ItemType": "directory",
"Path": "images"
},
{
"ItemType": "directory",
"Path": "samples"
},
{
"ItemType": "directory",
"Path": "tests"
},
{
"ItemType": "directory",
"Path": "types"
},
{
"ItemType": "file",
"Path": "changelog.md",
"Content": {
"value": "# Changelog",
"PSPath": "C:\work\sample\changelog.md",
"PSParentPath": "C:\work\sample",
"PSChildName": "changelog.md",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 1
}
},
{
"ItemType": "file",
"Path": "License.txt",
"Content": [
{
"value": "MIT License",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 1
},
{
"value": "",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 2
},
{
"value": "Copyright (c) 2021 JDH Information Technology Solutions, Inc.",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 3
},
{
"value": "",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 4
},
{
"value": "",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 5
},
{
"value": "Permission is hereby granted, free of charge, to any person obtaining a copy",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 6
},
{
"value": "of this software and associated documentation files (the \"Software\"), to deal",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 7
},
{
"value": "in the Software without restriction, including without limitation the rights",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 8
},
{
"value": "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 9
},
{
"value": "copies of the Software, and to permit persons to whom the Software is",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 10
},
{
"value": "furnished to do so, subject to the following conditions:",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 11
},
{
"value": "",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 12
},
{
"value": "",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 13
},
{
"value": "The above copyright notice and this permission notice shall be included in",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 14
},
{
"value": "all copies or substantial portions of the Software.",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 15
},
{
"value": "",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 16
},
{
"value": "",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 17
},
{
"value": "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 18
},
{
"value": "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 19
},
{
"value": "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 20
},
{
"value": "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 21
},
{
"value": "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 22
},
{
"value": "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 23
},
{
"value": "THE SOFTWARE.",
"PSPath": "C:\work\sample\License.txt",
"PSParentPath": "C:\work\sample",
"PSChildName": "License.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 24
}
]
},
{
"ItemType": "file",
"Path": "README.md",
"Content": {
"value": "# README",
"PSPath": "C:\work\sample\README.md",
"PSParentPath": "C:\work\sample",
"PSChildName": "README.md",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 1
}
},
{
"ItemType": "file",
"Path": "scratch-changelog.md",
"Content": {
"value": "# scratch change",
"PSPath": "C:\work\sample\scratch-changelog.md",
"PSParentPath": "C:\work\sample",
"PSChildName": "scratch-changelog.md",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 1
}
},
{
"ItemType": "file",
"Path": ".vscode\tasks.json",
"Content": [
{
"value": "{",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 1
},
{
"value": " // See https://go.microsoft.com/fwlink/?LinkId=733558",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 2
},
{
"value": " // for the documentation about the tasks.json format",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 3
},
{
"value": " \"version\": \"2.0.0\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 4
},
{
"value": " \"tasks\": [",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 5
},
{
"value": " {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 6
},
{
"value": " \"label\": \"Pester Test\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 7
},
{
"value": " \"type\": \"shell\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 8
},
{
"value": " \"command\": \"Get-Module Pester | Remove-Module;import-module -FullyQualifiedName @{ModuleName=\u0027Pester\u0027;RequiredVersion=\u00274.10.1\u0027};Invoke-Pester -Script ."\tests"\*test*.ps1 -PesterOption @{IncludeVSCodeMarker=$true}\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 9
},
{
"value": " \"options\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 10
},
{
"value": " \"shell\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 11
},
{
"value": " \"executable\": \"powershell.exe\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 12
},
{
"value": " \"args\": [",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 13
},
{
"value": " \"-noprofile\"",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 14
},
{
"value": " ]",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 15
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 16
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 17
},
{
"value": " },",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 18
},
{
"value": " {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 19
},
{
"value": " \"label\": \"Build markdown help files\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 20
},
{
"value": " \"type\": \"shell\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 21
},
{
"value": " \"command\": \"Import-Module $pwd"\*.psd1 -force;$module = Split-Path $pwd -leaf;New-MarkdownHelp -module $module -output $pwd"\docs -force\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 22
},
{
"value": " \"options\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 23
},
{
"value": " \"shell\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 24
},
{
"value": " \"executable\": \"powershell.exe\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 25
},
{
"value": " \"args\": [",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 26
},
{
"value": " \"-noprofile\"",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 27
},
{
"value": " ]",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 28
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 29
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 30
},
{
"value": " },",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 31
},
{
"value": " {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 32
},
{
"value": " \"label\": \"Add markdown help file\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 33
},
{
"value": " \"type\": \"shell\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 34
},
{
"value": " \"command\": \"Import-Module $pwd"\*.psd1 -force;$module = Split-Path $pwd -leaf;$cmd = Read-Host \u0027What command needs help?\u0027;New-MarkdownHelp -command $cmd -output $pwd"\docs -force;code $pwd"\docs"$cmd.md\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 35
},
{
"value": " \"options\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 36
},
{
"value": " \"shell\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 37
},
{
"value": " \"executable\": \"powershell.exe\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 38
},
{
"value": " \"args\": [",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 39
},
{
"value": " \"-noprofile\"",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 40
},
{
"value": " ]",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 41
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 42
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 43
},
{
"value": " },",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 44
},
{
"value": " {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 45
},
{
"value": " \"label\": \"Update markdown help file\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 46
},
{
"value": " \"type\": \"shell\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 47
},
{
"value": " \"command\": \"Import-Module $pwd"\*.psd1 -force;$module = Split-Path $pwd -leaf;$cmd = Read-Host \u0027What command needs UPDATED help?\u0027;Update-MarkdownHelp -path $pwd"\docs"$cmd.md -force;code $pwd"\docs"$cmd.md\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 48
},
{
"value": " \"options\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 49
},
{
"value": " \"shell\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 50
},
{
"value": " \"executable\": \"powershell.exe\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 51
},
{
"value": " \"args\": [",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 52
},
{
"value": " \"-noprofile\"",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 53
},
{
"value": " ]",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 54
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 55
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 56
},
{
"value": " },",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 57
},
{
"value": " {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 58
},
{
"value": " \"label\": \"Build PowerShell module external help\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 59
},
{
"value": " \"type\": \"shell\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 60
},
{
"value": " \"command\": \"c:"\scripts"\build-externalhelp.ps1\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 61
},
{
"value": " \"options\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 62
},
{
"value": " \"shell\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 63
},
{
"value": " \"executable\": \"powershell.exe\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 64
},
{
"value": " \"args\": [",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 65
},
{
"value": " \"-noprofile\"",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 66
},
{
"value": " ]",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 67
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 68
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 69
},
{
"value": " },",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 70
},
{
"value": " {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 71
},
{
"value": " \"label\": \"Push release to GitHub WHATIF\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 72
},
{
"value": " \"type\": \"shell\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 73
},
{
"value": " \"command\": \"c:"\scripts"\GitReleasePush.ps1 -whatif\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 74
},
{
"value": " \"options\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 75
},
{
"value": " \"shell\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 76
},
{
"value": " \"executable\": \"powershell.exe\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 77
},
{
"value": " \"args\": [",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 78
},
{
"value": " \"-noprofile\"",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 79
},
{
"value": " ]",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 80
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 81
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 82
},
{
"value": " },",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 83
},
{
"value": " {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 84
},
{
"value": " \"label\": \"Push PREVIEW release to GitHub\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 85
},
{
"value": " \"type\": \"shell\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 86
},
{
"value": " \"command\": \"c:"\scripts"\GitReleasePush.ps1 -PREVIEW\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 87
},
{
"value": " \"options\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 88
},
{
"value": " \"shell\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 89
},
{
"value": " \"executable\": \"powershell.exe\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 90
},
{
"value": " \"args\": [",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 91
},
{
"value": " \"-noprofile\"",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 92
},
{
"value": " ]",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 93
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 94
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 95
},
{
"value": " },",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 96
},
{
"value": " {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 97
},
{
"value": " \"label\": \"Push release to GitHub\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 98
},
{
"value": " \"type\": \"shell\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 99
},
{
"value": " \"command\": \"c:"\scripts"\GitReleasePush.ps1\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 100
},
{
"value": " \"options\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 101
},
{
"value": " \"shell\": {",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 102
},
{
"value": " \"executable\": \"powershell.exe\",",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 103
},
{
"value": " \"args\": [",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 104
},
{
"value": " \"-noprofile\"",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 105
},
{
"value": " ]",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 106
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 107
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 108
},
{
"value": " }",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 109
},
{
"value": " ]",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 110
},
{
"value": "}",
"PSPath": "C:\work\sample\.vscode\tasks.json",
"PSParentPath": "C:\work\sample\.vscode",
"PSChildName": "tasks.json",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 111
}
]
},
{
"ItemType": "file",
"Path": "formats\readme.txt",
"Content": {
"value": "These are formatting files for the module. This file can be deleted.",
"PSPath": "C:\work\sample\formats\readme.txt",
"PSParentPath": "C:\work\sample\formats",
"PSChildName": "readme.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 1
}
},
{
"ItemType": "directory",
"Path": "functions\private"
},
{
"ItemType": "directory",
"Path": "functions\public"
},
{
"ItemType": "file",
"Path": "functions\private\readme.txt",
"Content": {
"value": "This folder contains private module functions. This file can be deleted.",
"PSPath": "C:\work\sample\functions\private\readme.txt",
"PSParentPath": "C:\work\sample\functions\private",
"PSChildName": "readme.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 1
}
},
{
"ItemType": "file",
"Path": "functions\public\readme.txt",
"Content": {
"value": "This folder contains public module functions. This file can be deleted.",
"PSPath": "C:\work\sample\functions\public\readme.txt",
"PSParentPath": "C:\work\sample\functions\public",
"PSChildName": "readme.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 1
}
},
{
"ItemType": "file",
"Path": "tests\readme.txt",
"Content": {
"value": "Module Pester tests for the module. This file can be deleted.",
"PSPath": "C:\work\sample\tests\readme.txt",
"PSParentPath": "C:\work\sample\tests",
"PSChildName": "readme.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 1
}
},
{
"ItemType": "file",
"Path": "types\readme.txt",
"Content": {
"value": "These are custom type extension files for the module. This file can be deleted.",
"PSPath": "C:\work\sample\types\readme.txt",
"PSParentPath": "C:\work\sample\types",
"PSChildName": "readme.txt",
"PSDrive": "C",
"PSProvider": "Microsoft.PowerShell.Core\FileSystem",
"ReadCount": 1
}
}
]
我应该指出,该函数创建了一些可用于管理布局的元数据。
$meta = [pscustomobject]@{
Created = (Get-Date -Format g)
CreatedBy = $env:USERNAME
Computername = $env:COMPUTERNAME
Source = (Convert-Path $SourcePath)
Version = $version
}
在 Windows PowerShell 中,ConvertFrom-Json 具有意外的输出格式,因此在管道表达式中,通过管道传输到 ForEach-Object 可以解决此问题。我可能会构建一个命令来获取有关布局文件的信息,以简化此过程。
导入模块布局
有了这个 json 文件,我就可以重新创建它了。我需要做的就是指定新位置。该位置将是必须已经存在的父路径,例如 C:\Scripts 和新模块的名称。我可以导入 json 文件,对其进行转换,然后重新创建文件夹和文件。
ForEach-Object {
#create all the directories first
if ($_.Itemtype -eq 'directory') {
if ($pscmdlet.ShouldProcess($_.path, "Create directory")) {
New-Item -Path $modpath -Name $_.path -ItemType Directory -Force
}
} #directory item
elseif ($_.itemtype -eq 'file') {
if ($pscmdlet.ShouldProcess($_.path, "Create file")) {
$newFile = (Join-Path -Path $modPath -ChildPath $_.path)
Set-Content -Path $newfile -Value $_.content
Get-Item -path $newFile
}
} #file item
} #foreach-object
尽管像 New-Item 这样的命令支持 -WhatIf(我的导入函数也支持),但我正在编写自己的 Whatif 代码。这是因为如果路径不存在,Set-Content 命令将引发异常。
如果我对此感到满意,我就可以真正运行它。
几秒钟之内,我就创建了一个完整的模块结构,并为新项目做好了准备。
功能
我将把这些函数包含在我正在编写的新 PSFunctionTools 模块中。但欢迎您尝试一下。欢迎任何反馈或建议。
Function Export-ModuleLayout {
[cmdletbinding()]
[alias("eml")]
[OutputType("None","System.IO.FileInfo")]
Param(
[Parameter(Position = 0, Mandatory, HelpMessage = "Specify the model module path.")]
[ValidateScript( { Test-Path $_ })]
[string]$SourcePath,
[Parameter(HelpMessage = "Define a version number for this layout.")]
[string]$Version = "1.0",
[Parameter(HelpMessage = "Specify the name of the Json file to store the result.")]
[ValidateNotNullOrEmpty()]
[ValidatePattern("\.json$")]
[string]$FilePath = ".\modulelayout.json",
[Parameter(HelpMessage = "Show the file result.")]
[switch]$Passthru
)
Write-Verbose "Starting $($MyInvocation.MyCommand)"
$out = [System.Collections.Generic.list[object]]::New()
$meta = [pscustomobject]@{
Created = (Get-Date -Format g)
CreatedBy = $env:USERNAME
Computername = $env:COMPUTERNAME
Source = (Convert-Path $SourcePath)
Version = $version
}
$out.Add($meta)
Push-Location
#change location to the folder so that the relative path structure can be used.
Set-Location -path $SourcePath
Write-Verbose "Exporting directory structure from $Sourcepath"
Get-ChildItem -Recurse |
ForEach-Object {
$relPath = (Resolve-Path -Path $_.fullname -Relative) -replace "\.\", ""
Write-Verbose "Processing $relPath"
if ($_.Gettype().name -eq 'FileInfo') {
$f = [pscustomobject]@{
ItemType = "file"
Path = $relPath
Content = (Get-Content -Path $_.fullname)
}
$out.add($f)
}
else {
$d = [pscustomobject]@{
ItemType = "directory"
Path = $relPath
}
$out.Add($d)
}
} #foreach-object
Write-Verbose "Exporting module layout to $FilePath"
$out | ConvertTo-Json | Out-File -FilePath $FilePath
Pop-Location
if ($Passthru) {
Get-Item $Filepath
}
Write-Verbose "Ending $($myinvocation.MyCommand)"
}
function Import-ModuleLayout {
[CmdletBinding(SupportsShouldProcess)]
[alias("iml")]
[OutputType("none")]
Param(
[Parameter(Position = 0, Mandatory, HelpMessage = "What is the name of your new module?")]
[ValidateNotNullOrEmpty()]
[ValidatePattern("^\w+$")]
[string]$Name,
[Parameter(HelpMessage = "What is the parent path? The default is the current location")]
[ValidateScript( { Test-Path $_ })]
[string]$ParentPath = ".",
[Parameter(Mandatory, HelpMessage = "Specify the path to the module layout json file.")]
[ValidateScript({Test-Path $_ })]
[ValidatePattern("\.json$")]
[string]$Layout
)
Write-Verbose "Starting $($MyInvocation.MyCommand)"
$ParentPath = Convert-Path $ParentPath
Write-Verbose "Creating module layout for $name under $parentpath using layout from $layout."
$modpath = New-Item -Path $ParentPath -Name $name -ItemType Directory -Force
<#
ConvertFrom-Json has a bug in Windows PowerShell so
piping the converted content to ForEach-Object and
passing each object back to the pipeline works around it
#>
Get-Content -path $Layout |
ConvertFrom-Json | ForEach-Object {$_} |
Sort-Object -Property ItemType |
ForEach-Object {
#create all the directories first
if ($_.Itemtype -eq 'directory') {
if ($pscmdlet.ShouldProcess($_.path, "Create directory")) {
New-Item -Path $modpath -Name $_.path -ItemType Directory -Force
}
} #directory item
elseif ($_.itemtype -eq 'file') {
if ($pscmdlet.ShouldProcess($_.path, "Create file")) {
$newFile = (Join-Path -Path $modPath -ChildPath $_.path)
Set-Content -Path $newfile -Value $_.content
Get-Item -path $newFile
}
} #file item
} #foreach-object
Write-Verbose "Ending $($MyInvocation.MyCommand)"
}
我已经知道我想要进行一些更改,但是此代码现在可以运行并且满足我的要求。当然,我很好奇您可能有什么样的要求。
下次,我将向您展示我如何将最近的所有帖子放在一起。
猜你还喜欢
- 03-30 [玩转系统] 如何用批处理实现关机,注销,重启和锁定计算机
- 02-14 [系统故障] Win10下报错:该文件没有与之关联的应用来执行该操作
- 01-07 [系统问题] Win10--解决锁屏后会断网的问题
- 01-02 [系统技巧] Windows系统如何关闭防火墙保姆式教程,超详细
- 12-15 [玩转系统] 如何在 Windows 10 和 11 上允许多个 RDP 会话
- 12-15 [玩转系统] 查找 Exchange/Microsoft 365 中不活动(未使用)的通讯组列表
- 12-15 [玩转系统] 如何在 Windows 上安装远程服务器管理工具 (RSAT)
- 12-15 [玩转系统] 如何在 Windows 上重置组策略设置
- 12-15 [玩转系统] 如何获取计算机上的本地管理员列表?
- 12-15 [玩转系统] 在 Visual Studio Code 中连接到 MS SQL Server 数据库
- 12-15 [玩转系统] 如何降级 Windows Server 版本或许可证
- 12-15 [玩转系统] 如何允许非管理员用户在 Windows 中启动/停止服务
取消回复欢迎 你 发表评论:
- 精品推荐!
-
- 最新文章
- 热门文章
- 热评文章
[电视剧] 郑板桥(1991)全14集「绝版」【6.83G】
[软件合集] 25年6月17日 精选软件29个
[短剧] 2025年06月17日 精选+付费短剧推荐33部
[影视合集] 中国对越反击战影片
[电影] 雷霆特攻队(2025)1080P超清双语字幕+4K珍藏版官方中字版
[软件合集] 25年6月16日 精选软件25个
[软件合集] 25年6月15日 精选软件58个
[短剧] 2025年06月16日 精选+付费短剧推荐29部
[短剧] 2025年06月15日 精选+付费短剧推荐44部
[网赚] 今日头条微头条新手玩法揭秘:每天高收益实操教程,轻松变现不踩坑
[影视] 【香港】经典电影合集-170部(未删减版本)
[短剧] 2025年06月07日 精选+付费短剧推荐54部
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电视剧] 欢乐颂.5部全 (2016-2024)
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[短剧] 2025年06月15日 精选+付费短剧推荐44部
[剧集] 神经风云(2023)(完结).4K
[软件合集] 25年6月15日 精选软件58个
[剧集] [BT] [TVB] [黑夜彩虹(2003)] [全21集] [粤语中字] [TV-RMVB]
[短剧] 2025年06月17日 精选+付费短剧推荐33部
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[短剧] 2025年06月07日 精选+付费短剧推荐54部
[趣站] CS 1.6 在线版免费游玩,无需注册,支持多种游戏模式与地图
[软件合集] 25年6月6日 精选软件64个
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电影] 美国队长4 4K原盘REMUX 杜比视界 内封简繁英双语字幕 49G
[电影] 死神来了(1-6)大合集!
[软件合集] 25年05月13日 精选软件16个
[精品软件] 25年05月15日 精选软件18个
[绝版资源] 南与北 第1-2季 合集 North and South (1985) /美国/豆瓣: 8.8[1080P][中文字幕]
- 最新评论
-
- 热门tag