Help Desk Meet Power Shell
2015-12-14 16:58 Microsoft China TechNet Read 397
Share with you some of the views of desktop support and power shell.
Desktop technology Support, at first more mechanically repetitive single operations, such as the underlying hardware overhaul, intermediate system deployment, to the back of the system and software maintenance. The focus of this phase is "what to do" and "whether the problem is solved". After the accumulation of experience, more attention should be paid to the root of the problem, understand "why", find the root cause, fundamentally solve the problem, can really improve themselves. At the same time, only you can quickly find the root cause of the problem in order to quickly solve the problem. Based on the above, after which the desktop support for the upgrade, should be batch processing, with a script instead of manual repetition. The Power shell is definitely the best choice. Power Shell Technology is also a shortcut to desktop Technology Support transformation. AD, SCCM, Exchange, etc... The Power Shell definitely makes the GUI a shame in its efficiency. Especially after Exchange 2013, you rely more on the power shell.
Desktop support is more embarrassing on this issue. No desktop technical support engineer who specializes in C, Java python. There are also few desktop technical support engineers who specialize in power Shell. Even if you have a program ape that excels at power Shell or writes C to eat, they must not really understand the actual needs of a desktop technology support. Because the Tao is different.
So please do it yourself, from solving your own repetitive actions, releasing your own hands and starting to write the first power Shell script.
------------------------------------------------— Split Line---------------------------------------------------
It is recommended to use the Power shell ISE, you can integrate the ad, Exchange, SCCM and other modules all into a console, convenient, syntax highlighting and the combination of command and GUI, but also can help you to quickly transition from the GUI Shell.
650) this.width=650; "title=" clip_image001 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px, "alt=" clip_image001 "src=" Http://s3.51cto.com/wyfs02/M01/87/2A/wKioL1fWaSDyRU7KAACLLB0G9Ac953.jpg "border=" 0 "height=" 343 "/>
In this article, all the examples are completed on the client side without the permissions of the remote server. So you need to preinstall remote Server administration Tools; Exchange Management Tools; Configuration Manager Console.
Run power Shell as a domain administrator ISE
Import AD Module
PS c:\lionel> Import-module ActiveDirectory
Import Exchange Module
We can find the method of loading the Exchange module into Ise in the properties of the Exchange Management shell.
650) this.width=650; "title=" clip_image002 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "Alt=" Clip_ image002 "src=" http://s3.51cto.com/wyfs02/M02/87/2A/wKioL1fWaSGTsluAAACo6keU1eg337.jpg "border=" 0 "height=" 484 "/ > where you can see Target:c:\windows\system32\windowspowershell\v1.0\powershell.exe-noexit-command "." C:\Program Files\microsoft\exchangeserver\v15\bin\remoteexchange.ps1 '; Connect-exchangeserver-auto-clientapplication:managementshell
So we just need to run the following command in the power Shell to load the Exchange module.
PS c:\lionel>. ' C:\ProgramFiles\Microsoft\Exchange server\v15\bin\remoteexchange.ps1 '; Connect-exchangeserver-auto-clientapplication:managementshell
In the SCCM module, we can directly import the Power Shell module files from the installation directory of configuration Manager console.
PS c:\lionel> Import-module "C:\ProgramFiles (x86) \microsoft Configuration MANAGER\BIN\CONFIGURATIONMANAGER.PSD1"
After import, switch to the corresponding site.
Similarly, other server modules try to import in three ways. So that all the modules are in one console, you can invoke the commands in all the modules directly.
The following main introduction to the AD module
Verify that the Active Directory module was successfully imported by Get-module.
The question comes, what can we do with it.
There are a lot of things we can't start with.
It is more important to find a solution to the problem than how to solve it. In the age of big data, the Internet's information is mixed with fish eyes. I think no one knows more about their products than Microsoft. TechNet is highly recommended.
Here is the help page for the relevant module:
Active directoryadministration with Windows PowerShell: https://technet.microsoft.com/en-us/library/dd378937 (v= ws.10). aspx
Exchange2013 Power Shell: https://technet.microsoft.com/zh-cn/library/bb123778 (v=exchg.150). aspx
Skype for forbusiness Server Powershell: https://technet.microsoft.com/zh-cn/library/gg398867.aspx
SCMM Power Shell: https://technet.microsoft.com/zh-cn/library/gg398867.aspx
You can also view about power Shell videos at Microsoft Virtual Academy:
Quick Start : PowerShell 3.0: https://mva.microsoft.com/zh-cn/training-courses/-powershell-3-0-14443?l=Phq2m1PkB_3500115888
Using PowerShell for Active Directory: Https://mva.microsoft.com/en-US/training-courses/using-powershell-for-active-directory-8397?l=1btnFKJz _5104984382
and of course . Channel 9: Https://channel9.msdn.com/Search?term=Power%20shell#ch9Search
Finally, there is a good domestic blog, Power Shell Chinese Blog: http://www.pstips.net/powershell-online-tutorials/
These are referred to as modules.
can also be directly in Power Shell To view Help in. It is recommended that you update Powershell help before you use it . So that you can query for more comprehensive help information.
PS c:\lionel> Update-help
Query the Help information for a single command, you can use the Get-help
PS c:\lionel> get-help Get-aduser
or search for help information directly online.
PS c:\lionel> get-help Get-aduser-online
How to create accounts, update account attributes, delete accounts, and Computer, Group Management, please refer to the direct reference above TechNet page. It's very detailed inside. Don't say it anymore.
The batch process is described below.
we can use get-content Import a txt file. Thus , the TXT file in the user account or computer account to do batch processing.
For example, bulk query AD Account Information
650) this.width=650; "title=" clip_image003 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "Alt=" Clip_ image003 "src=" http://s3.51cto.com/wyfs02/M00/87/2A/wKioL1fWaSKyYmfqAAA6NVIOHDw851.jpg "border=" 0 "height=" 104 "/ > 650) this.width=650; "title=" clip_image004 "style=" border-top:0px;border-right:0px; background-image:none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px; padding-right:0px, "alt=" clip_image004 "src=" http://s3.51cto.com/wyfs02/M01/87/2C/ Wkiom1fwaslyiiw3aadexiqoixw122.jpg "border=" 0 "height=" 379 "/>
Query user account all properties
650) this.width=650; "title=" clip_image005 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "Alt=" Clip_ image005 "src=" http://s3.51cto.com/wyfs02/M02/87/2C/wKiom1fWaSTxiHWGAADhSODcw2o337.jpg "border=" 0 "height=" 484 "/ >
If you need to filter the individual attribute information for a user account, select it by using the pipe symbol with SELECT.
650) this.width=650; "title=" clip_image006 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "Alt=" Clip_ image006 "src=" http://s3.51cto.com/wyfs02/M01/87/2A/wKioL1fWaSXBz7SqAABYUL79JgA275.jpg "border=" 0 "height=" 131 "/ >
If you need to export the structure to a CSV file, use the Export-csv
PS c:\lionel> get-content. \checklist.txt | Get-aduser-properties * | Export-csv. \userinfo.csv
Reset AD user account Lionel password is P@ssw0rd
650) this.width=650; "title=" clip_image007 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "Alt=" Clip_ image007 "src=" http://s3.51cto.com/wyfs02/M02/87/2A/wKioL1fWaSXyaFh1AAAo4GX3MIQ489.jpg "border=" 0 "height=" 47 "/ >
Batch Reset user account password is P@ssw0rd
650) this.width=650; "title=" clip_image008 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "Alt=" Clip_ image008 "src=" http://s3.51cto.com/wyfs02/M00/87/2C/wKiom1fWaSbAB7dzAAAe2mbdMv0249.jpg "border=" 0 "height=" 31 "/ >
Reset different user accounts to the corresponding password (user account and password, one pair), complete with Forech.
The script reads as follows:
$importFile =import-csv. \updatead.csv
foreach ($z in $importFile)
{3
Get-aduser-identity $z. Alias | Set-adaccountpassword-reset-newpassword (Convertto-securestring-asplaintext $z. Password-force)
}
The CSV file format is as follows
650) this.width=650; "title=" clip_image009 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "Alt=" Clip_ image009 "src=" http://s3.51cto.com/wyfs02/M00/87/2A/wKioL1fWaSaCDpg9AAAi1IuyYJs026.jpg "border=" 0 "height=" 126 "/ >
Bulk Modify AD user account attributes, Set-aduser can only modify some of the ad user account attributes, some properties are not in Set-aduser. Similar requirements, or, due to private extended properties, can be updated with the following script, using the phone number as an example.
The script reads as follows:
$importFile =import-csv. \settelephonenumber.csv
foreach ($i in $importFile)
{
$User = get-aduser-identity $i. Alias-properties telephonenumber
$User. ' Telephonenumber ' = $I. telephonenumber
Set-aduser-instance $User
}
The CSV file format is as follows:
650) this.width=650; "title=" clip_image010 "style=" border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px, "alt=" clip_image010 "src=" Http://s3.51cto.com/wyfs02/M00/87/2A/wKioL1fWaSeSHEfZAAAkjty57_I343.jpg "border=" 0 "height="/>
These, just simple implementation of the function, has not added error handling, logs and so on. is also just getting started, still in the study, look forward to communicate with you, learn from each other.
Lionel Zhao @ December 12, 2015
This article from the "Erick" blog, declined to reprint!
Help Desk Meet Power Shell