Powershell: 用New-SelfSignedCertificate命令创建自签名证书
lesca | Powershell | 2017-07-06
1.创建根证书
$cert = New-SelfSignedCertificate -Type Custom -KeySpec Signature `
-Subject "CN=P2SRootCert" -KeyExportPolicy Exportable `
-HashAlgorithm sha256-KeyLength2048 `
-CertStoreLocation "Cert:\CurrentUser\My" `
-KeyUsageProperty Sign -KeyUsage CertSign
2.获取证书引用(可选步骤)
将下面的THUMBPRINT替换成所需证... [阅读全文]
Powershell基础教程:变量、循环、基本命令
本文介绍Powershell的基础知识。
一、准备工作
检查当前执行策略
Get-ExecutionPolicy [-list]
修改执行策略
Set-ExecutionPolicy {Unrestricted | RemoteSigned | AllSigned | Restricted }
Restricted – 不可运行Powershell脚本,只能使用命令行交互模式。
AllSigned – 只有经过可信发布者签名的脚本才可运行。
RemoteSign... [阅读全文]
Powershell: 获取指定深度的非继承目录的ACL信息
该Powershell脚本首先通过Get-ChildItemToDepth函数获取C盘下3层子目录的所有内容,然后通过管道导入getDirAcl过滤器,获取所有目录的Acl属性,再进入excludeAcl过滤器,以排除不需要的项。最后通过export-csv命令导出到csv文件。
Function Get-ChildItemToDepth {
...
# 单击链接查看函数定义
函数定义
}
# 获取目录的Acl属性
Filter get... [阅读全文]
Powershell: 获取非继承的目录子项信息
lesca | Powershell, Tutorials | 2012-10-24
该Powershell脚本将递归获取D盘目录下的所有具有非继承关系的目录,并列出目录名称、所有者、用户及其访问权限、同上层目录的继承关系。然后通过过滤器,输出不继承上层目录权限的目录。
get-childitem -recurse D: | where{_.psiscontainer} | get-acl | % {path = _.pathowner = _.owner_.access | % {
New-Object PSObject -Property @{
... [阅读全文]
Powershell: 按目录深度获取目录子项
lesca | Powershell, Tutorials | 2012-10-24
Get-ChildItemToDepth函数通过Path参数和ToDepth参数,递归获取Path下的ToDepth层目录路径,并输出到STDOUT,用户可以通过管道重定向到其他函数进行二次利用。
函数原型:
Get-ChildItemToDepth PathToDepth
函数定义:
Function Get-ChildItemToDepth {
Param(
[String]Path =PWD,
[Byte]ToDepth = 3,
[Byte]CurrentDepth = 0... [阅读全文]