
PowerShell
yangzhenping
我坚信让我一往无前的唯一力量就是我热爱我所做的一切!
展开
-
6.Querying WMI and 7.Working with Active Directory
<br />6.##################################################################################################Querying WMI<br />Get-WmiObject win32_bios<br />Get-WmiObject win32_computersystem<br />Get-WmiObject win32_computersystem | Format-List name,model, m原创 2010-09-03 17:20:00 · 2261 阅读 · 0 评论 -
Powershell example 4
<br />BulkCopy.ps1#BulkCopy.ps1Set-Location "C:/Logs"$files=Get-ChildItem |where {$_.extension -eq ".log"}foreach ($file in $files) { $filename=($file.FullName).ToString() $arr=@($filename.split(".")) $newname=$arr[0]+".old" Write-Host "copyi原创 2010-09-04 12:28:00 · 1458 阅读 · 0 评论 -
How to know one virtual machine is in which host?
How to know one virtual machine is in which host?Run powershell command: (get-item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").GetValue("HostName")原创 2013-04-27 11:06:20 · 1857 阅读 · 0 评论 -
Deploy SCO IP using Powershell
comObject.types.ps1xml System.__ComObject GetProperty $type = $this.gettype(); $type.invok原创 2013-09-26 15:43:10 · 2180 阅读 · 0 评论 -
PowerShell 5.0和跨平台PowerShell支持class类编程
PowerShell 5.0和跨平台PowerShell支持class类编程PowerShell 5.0支持class类编程,具体查看:https://technet.microsoft.com/en-us/library/dn820211.aspx这里给个最简单的例子:class A{[string]$nameA([string]$name){$this.name=$name}}$a=[A]::new("test")$a.name另外,微软这两年做的跨平台Pow原创 2016-04-01 16:10:29 · 2455 阅读 · 0 评论 -
微软刚刚发布开源跨平台PowerShell【赞!】
微软刚刚发布开源跨平台PowerShellhttps://blogs.msdn.microsoft.com/powershell/2016/08/18/powershell-on-linux-and-open-source-2/新的跨平台PowerShell是基于跨平台dotnet开发的新平台,可以使用PowerShell语言编程实现对Linux,Mac OSX,Windows的操作。原创 2016-08-19 11:15:38 · 2804 阅读 · 0 评论 -
PowerShell VS Bash
PowerShell VS Bash原创 2016-09-01 18:00:26 · 11626 阅读 · 4 评论 -
跨平台PowerShell如何远程管理Linux/Mac/Windows?
跨平台PowerShell如何远程管理Linux/Mac/Windows?原创 2016-09-02 12:39:47 · 11330 阅读 · 3 评论 -
8.Leveraging the Power of ADO and 9.Managing Exchange 2007
<br />8.##################################################################################################Leveraging the Power of ADO<br />$strQuery = "<LDAP://dc=nwtraders,dc=msft>;;name;subtree"<br />ou=myTestOU,dc=nwtraders,dc=msft<br />LDAP Dialect Que原创 2010-09-03 17:26:00 · 1601 阅读 · 0 评论 -
5.Using PowerShell Scripts and 5.Using WMI
<br />Get-ChildItem c:/fso | Where-Object {$_.Length -gt 1000} | Sort-Object -Property name<br />foreach ($i in $args) {Get-ChildItem $i | Where-Object {$_.length -gt 1000} | Sort-Object -property name}<br />$args = "localhost","loopback","127.0.0.1"<br />原创 2010-09-03 16:58:00 · 1675 阅读 · 0 评论 -
Type in PowerShell
1.Boolean<br />A "true" or "false" value. This type doesn't include any significant methods or properties. Note that PowerShell includes built-in variables named $true and $false that represent the two possible Boolean values:PS C:/> [boolean]$b = $trueP原创 2010-09-03 17:34:00 · 1620 阅读 · 0 评论 -
Powershell example 1
<br />Restart-Computers.ps1# Define input parametersparam ( [string] $filename = $(throw "Filename is required!"))Write-Host "Reading computer names from $filename"# Read file$computers = get-content $filenameforeach ($computer in $compu原创 2010-09-04 12:19:00 · 1602 阅读 · 0 评论 -
Powershell example 2
ProcessCPU.ps1#ProcessCPU.ps1$process=get-process$low=0 #counter for low cpu processes$med=0 #counter for medium cpu processes$high=0 #counter for high cpu processesforeach ($p in $process) {[int]$cpuseconds="{0:F0}" -f $p.cpu if ($cpusecon原创 2010-09-04 12:23:00 · 1514 阅读 · 0 评论 -
Powershell example 5
<br />SetPermswithCACLS.ps1#SetPermsWithCACLS.ps1# CACLS rights are usually# F = FullControl# C = Change# R = Readonly# W = Write$StartingDir=Read-Host " What directory do you want to start at?"$Right=Read-Host " What CALCS right do you wan原创 2010-09-04 12:31:00 · 1454 阅读 · 0 评论 -
Powershell example 3
Blocktest.ps1$sb = { foreach ($process in $input) { $process.ProcessName }}get-process | &$sbFunctiontest.ps1$a = "Hello"function foo ($b) { $b.ToUpper() $b.ToLower()}$x = foo $a$xScript1.ps1trap { write-host "YIKES!!原创 2010-09-04 12:25:00 · 1453 阅读 · 0 评论 -
Powershell example 6
<br />GetSecurityRSS.ps1#GetSecurityRSS.ps1#Query Microsoft's Basic Security Feed for latest bulletins#Critical bulletins will be displayed in Red#Important bulletins will be display in Yellow#Everything else will be displayed in Green[void] [S原创 2010-09-04 12:35:00 · 1346 阅读 · 0 评论 -
1.Overview of Windows PowerShell
PS C:/Documents and Settings/somebody> cd c:/ PS C:/> dirPS C:/> md c:/testPS C:/> cd c:/testPS C:/test> fsutil file createNew c:/test/myNewFile.txt 1000File c:/test/myNewFile.txt is createdPS C:/test> dirPS C:/test> del *.txtPS C:/test> cd c:/PS C:/> rd c原创 2010-09-03 16:49:00 · 1523 阅读 · 0 评论 -
2.Using Windows PowerShell Cmdlets and 3.Leveraging PowerShell Providers
<br />PS C:/> get-alias dir<br />PS C:/> get-childitem C:/<br />get-childitem |format-list<br />get-childitem C:/ | format-list -property name<br />get-childitem C:/ | format-list -property name, length<br />get-childitem C:/ | format-wide<br />get-childit原创 2010-09-03 16:55:00 · 1504 阅读 · 0 评论 -
跨平台PowerShell远程协议(PSRP)使用Basic认证将只支持HTTPS模式
上个月有人在跨平台PowerShell远程协议(PSRP)上发了一个bug:使用Basic认证和HTTP方式从Linux远程到Windows会报Access Denied https://github.com/PowerShell/psl-omi-provider/issues/114我troubleshooting了一两天发现是OMI已经禁用了这种不安全的方式,目前fix方式是在PowerShe...原创 2018-05-08 07:07:59 · 1367 阅读 · 0 评论