Windows PowerShell 配置Openssh for windows

cd C:\Programmi\OpenSSH\etc

mkgroup -l >>C:\Programmi\OpenSSH\etc\group


mkpasswd -l -u nome_utente >>C:\Programmi\OpenSSH\etc\passwd

Windows PowerShell Powershell中的左边填充

[string]$stringToPad = 1
$padChar = "X"
$paddedLength = 4
$stringToPad = ($padChar * ($paddedLength - $stringToPad.Length)) + $stringToPad

Windows PowerShell 远程激活远程桌面!

wmic /node:�RemoteServer� /user:�domain\AdminUser� /password:�password� RDToggle where servername=�RemoteServer� call SetAllowTSConnections 1

Windows PowerShell 批处理文件持续时间计算

@echo off
for /f "tokens=1-14 delims= " %%A in ('systeminfo ^| find "System Up Time"') do set /a secs1=86400*%%D+3600*%%F+60*%%H+%%J

rem nothing here

for /f "tokens=1-14 delims= " %%A in ('systeminfo ^| find "System Up Time"') do set /a secs2=86400*%%D+3600*%%F+60*%%H+%%J
set /a secs3=secs2-secs1
echo %secs3% seconds taken.
pause
robocopy "C:\source" "E:\destication" /e /r:0 /w:0

Windows PowerShell Windows DIR - 仅列出目录中所有文件的文件名

dir *.* /b >>fileListing.txt

Windows PowerShell 使用gacutil.exe从GAC卸载程序集

#find fully qualified assembly name
gacutil /l Microsoft.Practices.SharePoint.Common

#uninstall 
gacutil /u "Microsoft.Practices.SharePoint.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ef4330804b3c4129"

Windows PowerShell 获取SharePoint 2010版本号

get-spfarm | select BuildVersion

BuildVersion
------------
14.0.5050.5001

Windows PowerShell 通过Powershell更改SP 2010中的主页

$web = Get-SPWeb http://sharepoint 

$web.CustomMasterUrl = "/_catalogs/masterpage/v4.master" 

$web.MasterUrl = "/_catalogs/masterpage/v4.master" 

$web.Update()

Windows PowerShell Powershell剪断

#Build SQLCMD line for all files in the directory.

dir tables|foreach{$a = $_.Name;"r: Tables\$a"}>201106_Deploy.sql

#Generate random passwords
-join ([Char[]]'abcdefgABCDEFG0123456&%$' | Get-Random -count 20)

#Generate a range of letters base on the ascii code (e.g. A: B:...)
65..90 | Foreach-Object { "$([char]$_):" }

<#Reading Text Files Fast - returns String#>

$a = [System.IO.File]::ReadAllText("$path\wkspace.csv")

<#Reading Text Files fast - returns Array
Measure-command returns time to execute metadata#>

measure-command{[System.IO.File]::ReadAllText("$path\wkspace.csv")}