❶ powershell和powershell ise到底分別干什麼用,powershell命令那麼長怎麼記
主要是更方便進行遠程管理和詳細的管理,相對於DOS更加強大。
壞處是沒有的,WinXP預裝是沒有Powershell的,Vista預裝Powershell1.0,Win7預裝Powershell2.0,Win8預裝Powershell3.0.
點開始,點運行,輸入Powershell就可以了,Powershell就是一個DOS的命令行工具而已。跟DOS一模一樣的,更強大一點而已。
你也可以在運行裡面輸入Powershell_ISE,這個是一個集成開發環境,用來寫腳本的,寫完的腳本後綴是PS1,用來代替VBS和Bat文件的。
❷ 如何用幫助系統獲取PowerShell可用命令信息
PowerShell的設計者在設計幫助系統的過程中嘗試使其簡單易用,適應盡可能多的用戶使用。所有針對內置命令的幫助內容均用英語做了詳細的說明,用戶可以使用Get-Help這個cmdlet來查詢任何命令的幫助信息。PowerShell也提供了help命令,這是一個調用Get-Help的函數。執行後將輸出管道傳輸到more.com,這樣用戶即可分頁閱讀有關的幫助內容。
1.1 基礎知識
在控制台提示符下鍵入help,按回車鍵後提示help的相關信息,從中可以看到help是Get-Help重新封裝過的:
PS C:\Documents and Settings\Administrator> help
TOPIC
Get-Help
SHORT DESCRIPTION
Displays help about Windows PowerShell cmdlets and concepts.
LONG DESCRIPTION
SYNTAX
get-help {<CmdletName> | <TopicName>}
help {<CmdletName> | <TopicName>}
<CmdletName> -?
Examples:
get-help get-process : Displays help about the Get-Process cmdlet.
get-help about_signing : Displays help about the signing and execution pol
icies.
help where-object : Displays help about the Where-Object cmdlet.
help about_foreach : Displays help about foreach loops in PowerShell.
set-service -? : Displays help about the Set-Service cmdlet.
……
可以嘗試使用通配符過濾主題,下例中顯示所有以「about_」開頭的cmdlet的幫助:
PS C:\> help about_*
Name Category Synopsis
---- -------- --------
about_aliases HelpFile Describes how to use alternate n...
about_Arithmetic_operators HelpFile Describes the operators that per...
about_arrays HelpFile A compact data structure for sto...
about_Assignment_operators HelpFile Describes how to use operators t...
about_Automatic_variables HelpFile Describes variables that store s...
about_break HelpFile A statement for immediately exit...
about_install_wsman HelpFile Installs the required version of...
-- More --
可以調用help並傳遞需要顯示的主題名:
PS C:\> help ac
NAME
Add-Content
SYNOPSIS
Adds content to the specified items, such as adding words to a file.
……
上例將Add-Content的別名ac傳遞給help,相當於獲取Add-Content的幫助:
PS C:\> help Add-Content
NAME
Add-Content
SYNOPSIS
Adds content to the specified items, such as adding words to a file.
……
PowerShell為所有已經聲明的別名自動添加幫助主題,用戶不必知道別名指向的cmdlet,即可同時獲取別名及其對應的cmdlet的幫助。
在上述幫助主題中的每個主題都有個關聯分類,為所有的內置主題獲取分類值可以使用Get-Help cmdlet。下例將集合用管道傳遞給select獲取唯一的分類值:
PS C:\> Get-Help * | select Category -Unique
Category
--------
Alias
Cmdlet
Provider
HelpFile
從中可以看到以下分類值。
(1)Alias:為所有別名自動創建的主題。
(2)Cmdlet:如何使用cmdlet、內置或第三方管理單元的主題文檔。
(3)Provider:所有已安裝提供程序的主題文檔,PowerShell提供的內置提供程序的文檔包括Alias、Environment、FileSystem、Function、Registry、Variable和Certificate,完整的自定義提供程序應該添加主題到這個分類中。
(4)HelpFile:概念主題,所有討論特定語言特性,如分支、循環及變數的about_*主題均屬於該分類。
(5)Get-Help:找回基於分類名的主題,下例獲取特定語言的主題或者HelpFile分類:
PS C:\> Get-Help -Category HelpFile
Name Category Synopsis
---- -------- --------
about_aliases HelpFile Describes how to use alternate n...
about_Arithmetic_operators HelpFile Describes the operators that per...
about_arrays HelpFile A compact data structure for sto...
about_Assignment_operators HelpFile Describes how to use operators t...
Get-Help和help支持的另外一個重要參數是控制為用戶輸出的文本數量,可以通過使用-detailed、-full和-example開關來控制。可能的配置如下。
(1)無(默認值):返回值是關於命令簡短的介紹,其中包含支持的參數、簡短的描述及一兩個實例。
(2)-detailed:返回值是較為詳細的解釋,包括所有參數作用的詳細描述,同時附帶一系列命令操作的實例。
(3)-full:返回值是所有的幫助信息,包括所有參數的完整信息,以及實例的詳細信息。
(4)-example:返回值是完整的實例描述,包括標題、描述和示例代碼, 不會返回其他命令的信息。
1.2 參數的詳細信息
很多情況下,用戶可能只對命令中的一個參數感興趣,使用Get-Help的-parameter參數獲取特定參數的信息。下例獲取Get-ChildItem的-filter參數的信息:
PS C:\> Get-Help Get-ChildItem -Parameter filter
-Filter <string>
Specifies a filter in the provider's format or language. The value of this
parameter qualifies the Path parameter. The syntax of the filter, including
the use of wildcards, depends on the provider. Filters are more efficient
than other parameters, because the provider applies them when retrieving th
e objects, rather than having Windows PowerShell filter the objects after t
hey are retrieved.
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? False
其中的內容是參數的簡短描述和格式化後的參數規格清單,包括是否必需、位置(如果是與位置相關的參數)、默認值、管道輸入是否被解釋為參數值,以及是否支持通配符等。
❸ 如何用 PowerShell 分割文本文件
解決辦法:
ps | select * >pslist.txt
$pslist=gc pslist.txt
#按空格分隔文件
$pslist|%{$i=1}{
if($_){$_ >>"ps$i`.txt"}else{$i++}
}
#按內容和id修改文件名(因為有重名的所以加了id)
dir |?{$_.name -match 'psd+.txt'}|%{
$newname=((gc $_)[1].split(":")[1]).Trim()
$id=((gc $_)[14].split(":")[1]).Trim()
Rename-Item $_ ($newname + $id+ ".txt")
}
❹ powershell 復制命令
$sd=@("E:\a","E:\b") #設置源文件夾
$dd="d:\" #設置目標路徑
foreach($Directory in $sd){
$filelist=Get-ChildItem $Directory -r -fi *.pdf #獲取pdf文件列表
foreach($file in $filelist){
Copy-Item -Path $file.FullPath -Destination $dd -Force #拷貝文件到目標文件夾
}
}
❺ cmd中for循環怎麼寫
你這界面是powershell吧,不是cmd,這兩個東西語法不一樣的,你可以打個ls看看,如果能看到執行就是powershell的,如果不能那就是cmd,你說的for /l 這種是cmd下的寫法,在powershell中則是跟編程語言差不多,類似於
for($x=1; $x -lt 10; $x=$x+1)
{
echo $x
}
❻ 怎麼查看windows powershell有哪些命令
啟動方法
Win10系統可以在Cortana搜索框中輸入PowerShell就可以打開了
Win7/8.1系統可以使用Win+Q組合鍵打開搜索,然後輸入PowerShell,選擇下面的提示項就可以了
通用方法:Win+R組合鍵打開運行命令,輸入PowerShell按回車就可以打開了
從cmd切換至PowerShell:可以在命令提示符中輸入PowerShell就可切換至Windows PowerShell了
從PowerShell切換至cmd:在PowerShell下輸入cmd就可以切回cmd了
❼ powershell 什麼 命令
關於PowerShell命令的一些基本知識
•PowerShell的命令叫做cmdlet
•具有一致的命名規范,都採用動詞-名詞形式,如New-Item
•動詞部分一般為Add、New、Get、Remove、Set等
•命令的別名一般兼容Windows
Command以及Linux
Shell,如Get-ChildItem命令使用dir或ls均可
•PowerShell
命令產生的結果都是DLR對象
•PowerShell命令不區分大小寫
以文件操作為例講解PowerShell命令的基本用法
•新建目錄
New-Item
b2
-ItemType
Directory
•新建文件
New-Item
a.txt
-ItemType
File
•刪除目錄
Remove-Item
b2
•遞歸列pre開頭的文件或目錄,只列出名稱
Get-ChildItem
-Recurse
-Name
-Filter
"pre*「
•顯示文本內容
Get-Content
a.txt
•設置文本內容
Set-Content
a.txt
-Value
"content1「
•追加內容
Add-Content
a.txt
-Value
「content2「
•清除內容
Clear-Content
a.txt
❽ powershell命令行如何用forfiles命令調用gcc編譯多個文件
forfiles不是Powershell的命令,可以用foreach對文件進行遍歷,命令大概如下:
Get-ChildItem-PathF: ew_folder|ForEach-Object{gcc-o$_.FullName}
註解:
gcc的使用及參數我不知道,所以gcc -o $_.FullName只是一個示例。
Powershell獲取的都是對象,FullName屬性表示該對象(文件)的完整路徑。
ForEach-Object可以用%代替,即上面的命令行可以寫成
Get-ChildItem-PathF: ew_folder|%{gcc-o$_.FullName}
如有問題請追問,一直交流。
❾ powershell 命令
假如你的文本保存在C盤根目錄下的a.csv中(如果是csv文件,可以另存一下,Powershell讀取Excel的內容太麻煩),在第一行添加欄位名String1,示例如下:
$chars=import-csvC:a.csv
foreach($charin$chars){
$a=$char.String1
$a=$a.tochararray()
[array]::Reverse($a)
-join$a|Add-Content-PathC:.txt
}
其實這個翻轉也可以用Excel公式迭代實現:
1. 在B1中輸入以下公式:
=IF($D$1,B1&RIGHT(LEFT(A1,IF($D$2>LEN(A1),0,LEN(A1)-$D$2+1))),"")
2. 在D2中輸入以下公式:
=IF(D1,D2+1,0)
在D1中輸入1回車,則公式執行,完成翻轉;在D1中輸入0,則B列清空,D1重新輸入0,則重新進行計算。
❿ powershell循環語句:依次讀取某文件名並賦給變數,然後將該變數帶入一條命令進行執行;。變數:value。
給你寫個例子:
$filelist=dir xxxx #獲取文件列表
foreach($file in $filelist){
$filename=$file.fullname
Import-RecipientDataProperty -Identity $filename -Picture -FileData ([Byte[]]$(Get-Content-Path "D:\value.JPG" -Encoding Byte -ReadCount 0)) #做處理
xxxxx #表達式
}