本文共 1173 字,大约阅读时间需要 3 分钟。
$targetCertificate = Get-Childitem -Path Cert:\LocalMachine\My | where {$_.Thumbprint -eq $certThumbprint}#Get-Childitem 获取路径Cert:\LocalMachine\My下的文件列表#Cert:\LocalMachine\My 为Windows安装证书的路径##where-object 条件过滤,将路径下所有 Cert.Thumbprint == "证书密钥" 的证书文件返回#$certThumbprint 证书密钥#$targetCertificate.GetType() == System.Security.Cryptography.X509Certificates.X509Certificate
$data = Invoke-RestMethod -Uri $Uri -Certificate $targetCertificate#通过WebService公开的URI来获取对应的资源#URI中符号的意义 # ? :分隔实际的 URL 和参数 # = :URL 中指定参数的值 # + :URL 中+号表示空格 %2B # 空格 :URL中的空格可以用+号或者编码代替 # % :指定特殊字符 # # :表示书签 # & :URL 中指定的参数间的分隔符 # $ :后跟变量名
$data.value | Select @{ L="System";E={"TFS"}}, ID, Severity, Title | ft -a #Select-Object 选择对象的 ID, Severity, Title 部分属性,来用于显示。 通过结合管道来筛选# ft 格式化工具 (Format table)就是格式化为表格
将模块文件导入到当前脚本的环境变量中
Invoke-Expression ".\module.ps1"
$LocalDir = Join-Path -Path $Env:public -ChildPath ps-dir #Join-Path 将路径和子路径连接成一个单独的路径. 路径分隔符由提供程序提供.
管道操作与?结合
dir *.psd1 | ? { $_.Name -ne "mod-f5.psd1" } #将管道左边的输出当成管道右边的输入,并且返回能够满足管道右边条件的对象
转载地址:http://fuhpl.baihongyu.com/