❶ 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 #表达式
}