您的最佳的信息源和新聞 司機, 硬件 并且 景色硬件 在互聯網

景色文章 名列前茅50 景色錄影 景色軟 景色幫助

PowerShell

您當前瀏覽文章從 微軟視窗景色兼容軟件 匹配類別 PowerShell.

遙遠地重新起動計算機與WMI和PowerShell

要做的其中一件最棘手的事,當與估計一起使用遙遠地是重新起動他們。 我們必須也確信,計算機沒有可能造成他們不重新開始的任何生物活素問題。 如果他們的終端服務通入被關閉,許多次我們不可能甚而得到註冊。 以這個把戲您能容易地重新起動服務器,沒有安裝的PowerShell甚而的一个。

要做這第一我們在有PowerShell的計算機得到。 在PowerShell提示,嘗試:

PS C:\> $your_server = gwmi win32_operatingsystem -計算機 yourservername

如果您跟隨最佳的實踐,并且不跑在領域admin帳戶, (或是地方admin在所有您的服務器)的帳戶之下您應該然後看像這樣的一個錯誤:

現在我們想要能到停工每計算機,但我們需要確定我們使用一個帳戶以允許重新起動在考慮中的計算機。

您能使用runas CMD命令發射PowerShell與必要的證件。

PS C:\> runas /env /user :administrator@domain.local 「powershell.exe」

然後您能與您的可變物連接另一臺計算機,并且射擊簡單的重新起動方法。

PS C:\> $your_server = gwmi win32_operatingsystem -計算機 yourservername

點擊持續遙遠地讀「重新起動計算機與WMI和PowerShell」

由daniel.nerenberg寫 2007年5月18日沒有評論.
讀更多文章 PowerShell.

創造一名廣告用戶在PowerShell

PowerShell允許您讀,寫和更新活躍目錄對象。 與PowerShell的許多其他先進的特點一道這提供一個巨大環境處理您的廣告和自動化任務。

創造用戶對象:

首先我們需要設置可變物拿著領域對象,并且與領域連接事例。

PS C:\> $domain = [ADSI] 「LDAP ://main :389/dc=domain, dc=local」

這將允許您與廣告互動從使用這$domain可變物。

您能通過鍵入列出您的領域根:

PS C:\> $domain.psbase. Get_children ()

這將由卓越的名字在您的活躍目錄列出根容器。

要得到關於一個具體分支的更多信息在目錄我們可以同那個分支聯繫在一起到新的可變物。

$usersOU = [ADSI] 「LDAP ://CN=Users, DC=domain, DC=local」

并且另外使用「psbase。Get_children ()」

$usersOU.psbase.Get_children ()

這將列出所有廣告對象(用戶和計算機)在OU。

讓通過創造用戶完成。

PS C:\> $newUser = $usersOU.Create(”user”,”cn=MyNewUser”)
PS C:\> $newUser.put(”title”, “PowerShell Test Account”)
PS C:\> $newUser.put(”employeeID”, 123)
PS C:\> $newUser.put(”description”, “Test User Account for LazyAdmin Demo”)
PS C:\> $newUser.SetInfo()

Now If you enter this into your command prompt you may get an access denied error:

This is

Click to continue reading "Create an AD user in PowerShell"

Written by daniel.nerenberg on May 14th, 2007 with no comments.
Read more articles on PowerShell.

PowerShell DIY commands (using functions)

As you might have guessed I’m a lazy admin :) Now being a lazy admin doesn’t mean I sit around pondering whether captain Kirk is better than Captain Picard, and all the while, hope somebody is taking care of what I’m supposed to be doing. It means I work smarter not harder. Yes I know 2 clichés in the same paragraph. And everyone knows Picard is totally the best Captain.

So the point of all this is PowerShell has this awesome feature for creating functions. What is a function? Well for those who don’t have a programming/developers background, a function is a chunk of code that performs an easily reusable set of instructions.

To draw an analogy, a car has many parts. Each part performs a specific function. If we were to lump every function of every part of a car into one giant part it would be much harder to design. It would also be harder to fix, and much more expensive to replace.

When programmers code applications they use the same idea. If they write up some code that does one thing very well. For instance format a string of text; they will often put this generic code

Click to continue reading "PowerShell DIY commands (using functions)"

Written by daniel.nerenberg on May 9th, 2007 with no comments.
Read more articles on PowerShell.

No older articles

Newer articles »