Power shell

Powershell学习方法:

善用官方命令帮助文档Get-Help(别名Man和Get-Help是一个命令)命令

例如:要学习New-ADusers命令,创建账号。不知道有哪些语法,参数属性可以用怎么用?就可以用Get-Help+命令 ,查询在线文档帮助或是终端文档帮助。

 

终端New-Adusers命令文档帮助

Get-Help  New-ADusers

New-ADusers在线文档帮助

Get-Help  New-ADusers  -online 

 

相关链接

Online Version: http://go.microsoft.com/fwlink/p/?linkid=291077
Get-ADUser
Remove-ADUser
Set-ADUser

备注
若要查看示例,请键入: "get-help New-ADUser -examples".
有关详细信息,请键入: "get-help New-ADUser -detailed".
若要获取技术信息,请键入: "get-help New-ADUser -full".
有关在线帮助,请键入: "get-help New-ADUser -online"

 

---------------------------------------------------------------------------------------------------------------------------------------------------------------

 

 

Power shell 学习教程:

PowerShell 中文博客 – 收集和分享 Windows PowerShell 相关教程,技术和最新动态 (pstips.net)

 

Powershell文档帮助:

安装 Windows PowerShell - PowerShell | Microsoft Docs

 

Power shell 命令语法使用:

Add-Computer (Microsoft.PowerShell.Management) - PowerShell | Microsoft Docs

 

查看Power shell版本命令:host 、$PSVersionTable

 

命令在线文档帮助:

Help Get-Process -Online

 

Power shell批量创建新文件和文件夹命令

 

 

删除文件

-recurse没有提示强制删除

Remove-Item  文件路径   -recurse

批量删除文件夹

 

 

实例:

用Power shell 命令,将电脑本地文件备份到其他磁盘中或是NTFS文件共享或是NASA共享中。

参考博客:使用PowerShell实现自动备份文件夹_zhang_ruisen的博客-CSDN博客_powershell 导出文件

$Source_Path="C:\file"

$DESTINATION_HOME="D:\Back_up_file"

$Destination_Path=$DESTINATION_HOME+“\”+(Get-Date).ToString("yyyyMMdd")

if(!(Test-Path $Destination_Path))

  {  

  New-Item -ItemType Directory -Path $Destination_Paht

  }

foreach($Path in $Source_Path)

  {

  Copy-Iten -Path $Path -Destination $Destination_Path -Recurse -Force

  }

 

posted @ 2022-04-14 10:26  learn_7  阅读(386)  评论(0)    收藏  举报