Windows Server 2012 PowerShell 概览
- 格式:pdf
- 大小:720.83 KB
- 文档页数:29
powershell使用手册PowerShell是一种任务自动化和配置管理框架,它由微软开发并集成到其操作系统中。
它的强大之处在于其灵活性和可扩展性,可以用于管理Windows操作系统上的各种任务和配置。
以下是关于PowerShell的使用手册:1. 基础知识,PowerShell的基本语法和命令结构是了解其功能的第一步。
了解如何编写和执行基本的命令,如何使用变量和管道操作符等是非常重要的。
2. Cmdlet,Cmdlet是PowerShell中的命令,它们以动词-名词的形式命名,例如Get-Process,Start-Service等。
掌握常用的Cmdlet以及它们的用法是非常重要的。
3. 脚本编写,PowerShell可以用于编写脚本来自动化任务。
了解如何编写脚本以及如何运行和调试脚本是非常重要的。
4. 远程管理,PowerShell可以用于远程管理其他计算机。
了解如何配置远程管理以及如何在远程计算机上执行命令和脚本是非常重要的。
5. 模块和函数,PowerShell支持模块和函数,可以通过这些方式扩展其功能。
了解如何编写和使用模块以及函数是非常重要的。
6. 错误处理和日志记录,了解如何处理错误以及如何记录日志对于编写健壮的PowerShell脚本是非常重要的。
7. 安全性,PowerShell具有强大的系统管理功能,因此安全性是非常重要的。
了解如何配置执行策略以及如何安全地使用PowerShell是非常重要的。
总之,掌握PowerShell的使用需要不断的实践和学习,通过阅读官方文档和参考书籍可以更好地掌握PowerShell的用法和技巧。
希望这些信息对你有所帮助。
powershell常用命令总结PowerShell是一种功能强大的脚本语言和命令行工具,旨在帮助用户自动化管理和配置Windows操作系统。
作为一名系统管理员或开发人员,熟练掌握PowerShell的常用命令是非常重要的。
在本文中,我将向你介绍一些最常用的PowerShell命令,并为你提供详细的步骤和示例。
首先,我们来了解一下PowerShell的优势。
与其他命令行工具相比,PowerShell 具有以下几个重要特点:1. 管道(Piping):允许将一个命令的输出作为另一个命令的输入,实现更高效的数据处理和操作。
2. 通用性:PowerShell可以管理和配置不仅仅是Windows操作系统,还包括其他Microsoft产品和第三方应用程序。
3. 面向对象:PowerShell是基于.NET框架的,支持面向对象的编程和操作,提供了丰富的类库和API。
4. 可扩展性:通过编写脚本和自定义模块,你可以轻松扩展和定制PowerShell 的功能。
在接下来的内容中,我们将学习一些常用的PowerShell命令,并分析它们的应用场景和用法。
一、基本命令1. Get-Command:获取所有可用命令或查询特定命令的信息。
例如,你可以使用“Get-Command”来获取PowerShell中所有的命令列表。
powershellGet-Command2. Get-Help:获取命令的使用帮助和文档。
在PowerShell中,你可以通过“Get-Help”命令来获取任何命令的详细说明。
powershellGet-Help Get-Process3. Set-Location和Get-Location:用于切换和获取当前目录。
这些命令与常用的cd和pwd命令类似。
powershellSet-Location C:\Windows\System32Get-Location4. Clear-Host:清除控制台窗口的内容,使其保持清洁。
Windows PowerShell使用说明Windows PowerShell使用说明Windows PowerShell是一种命令行外壳程序和脚本环境,使命令行用户和脚本编写者可以利用 .NET Framework的强大功能。
本期TT虚拟化技术手册介绍Windows PowerShell的使用方法,还会涉及到VMware PowerCLI的相关信息。
PowerShell与Hyper-VSCVMM和Hyper-V PowerShell cmdlets帮助虚拟机环境的管理员开启了新的管理模式。
PowerShell不仅能对Hyper-V进行监控与测试,还能克服Hyper-V热迁移限制,您需要掌握哪些命令呢?Hyper-V PowerShell中的常用命令简介使用PowerShell进行Hyper-V监控与测试使用PowerShell克服Hyper-V热迁移限制PowerShell与PowerCLI拿VMware的PowerCLI与微软的PowerShell作比较似乎是太可能,因为前者需要后者先安装好,且它仅是一个针对核心PowerShell环境的供应商指定附加物。
两者结合能发挥很大作用。
VMware PowerCLI和微软PowerShell谁好?使用PowerShell与PowerCLI自动化主机服务器任务在vSphere PowerCLI PowerShell界面使用host profiles跳出框外巧解PowerShell与PowerCLI难题PowerShell管理技巧Windows 7远程桌面管理?Citrix XenDesktop 5管理?PowerShell都能掌控。
PowerShell管理Windows 7远程桌面的技巧使用Windows PowerShell管理Citrix XenDesktop 5使用Windows PowerShell管理远程桌面设备Hyper-V PowerShell中的常用命令简介对于虚拟机、宿主机和任务进程而言,微软Hyper-V管理控制台和SCVMM (System Center Virtual Machine Manager)都是很不错的管理工具。
PoserShell中文站: PowerShell中文技术交流社区PowerShell中文站:Windows PowerShell 是微软公司为 Windows 环境所开发的壳程式(shell)及脚本语言技术,采用的是命令行界面。
这项全新的技术提供了丰富的控制与自动化的系统管理能力。
PowerShell是一款基于对象的shell, 建立在.Net框架之上, 目前支持.Net Framework 2.0. 能够运行在Windows XP SP2, Windows Vista, Windows 2003操作系统上. 能够同时支持WMI, COM, , ADSI等已有的Windows管理模型。
这项全新的技术提供了丰富的控制与自动化的系统管理能力;而“脚本语言”(scripting languages)则是用来编写程序的计算机语言。
脚本语言通常都有简单、易学、易用的特性,目的就是希望能让写程序的人(开发者)快速完成程序的编写工作。
PowerShell可以方便地查看和结束系统内的进程,PowerShell还支持将其设置为别名使用,PowerShell还有着管理系统服务、操作注册表和众多的网络相关操作。
Windows PowerShell™ 入门Microsoft Corporation发布日期:2006 年 9 月摘要Windows PowerShell™ 是专为系统管理员设计的新 Windows 命令行外壳程序。
该外壳程序包括交互式提示和脚本环境,两者既可以独立使用也可以组合使用。
本文档介绍了 Windows PowerShell 的基本概念和功能,并提供了一些使用 Windows PowerShell 进行系统管理的建议方法。
目录Windows PowerShell 入门版权声明......................................................................................................Windows PowerShell 简介....................................................................................................................目标受众............................................................................................................................................关于 Windows PowerShell....................................................................................................................可发现特性........................................................................................................................................一致性...............................................................................................................................................交互式脚本环境.................................................................................................................................面向对象............................................................................................................................................易于过渡到脚本.................................................................................................................................安装和运行 Windows PowerShell.........................................................................................................安装要求............................................................................................................................................安装 Windows PowerShell................................................................................................................运行 Windows PowerShell................................................................................................................Windows PowerShell 基础知识.............................................................................................................理解重要的 Windows PowerShell 概念.................................................................................................命令不是基于文本的......................................................................................................................命令系列是可扩展的......................................................................................................................Windows PowerShell 处理控制台输入和显示...............................................................................Windows PowerShell 使用某些 C# 语法.......................................................................................了解 Windows PowerShell 名称............................................................................................................名词名称以减少命令记忆量.............................................................................使用动词 -”Cmdlet “Cmdlet 使用标准参数....................................................................................................................帮助参数 (?)...............................................................................................................................通用参数....................................................................................................................................建议参数....................................................................................................................................获取摘要命令信息.................................................................................................................................显示可用命令类型.........................................................................................................................获取详细帮助信息.................................................................................................................................使用熟悉的命令名称.............................................................................................................................解释标准别名.................................................................................................................................2创建新别名....................................................................................................................................使用 Tab 扩展来自动完成名称..............................................................................................................对象管道...............................................................................................................................................了解 Windows PowerShell 管道............................................................................................................查看对象结构 (Get-Member).................................................................................................................使用格式命令更改输出视图...................................................................................................................使用 Format-Wide 输出单个项目...................................................................................................使用 Column 控制 Format-Wide 显示........................................................................................使用 Format-List 显示列表视图.....................................................................................................使用 Format-List 和通配符来获取详细信息...............................................................................使用 Format-Table 显示表格格式输出...........................................................................................改进 Format-Table 输出 (AutoSize)...........................................................................................Format-Table 输出在列中换行 (Wrap).......................................................................................组织表输出 (-GroupBy)..............................................................................................................使用 Out-* Cmdlet 重定向数据..............................................................................................................对控制台输出进行分页 (Out-Host).............................................................................................放弃输出 (Out-Null)....................................................................................................................打印数据 (Out-Printer)...............................................................................................................保存数据 (Out-File).................................................................................................................... Windows PowerShell 导航....................................................................................................................在 Windows Powershell 中管理当前位置..............................................................................................获取当前位置 (Get-Location).........................................................................................................设置当前位置 (Set-Location).........................................................................................................保存和撤回最近的位置( Push-Location 和 Pop-Location).........................................................管理 Windows PowerShell 驱动器........................................................................................................添加新的 Windows PowerShell 驱动器 (New-PSDrive)................................................................删除 Windows PowerShell 驱动器 (Remove-PSDrive).................................................................在 Windows PowerShell 外部添加和删除驱动器...........................................................................处理文件、文件夹和注册表项...............................................................................................................枚举文件、文件夹和注册表项 (Get-ChildItem)..............................................................................列出所有包含的项 (-Recurse)....................................................................................................按名称筛选项 (-Name)...............................................................................................................强制列出隐藏项 (-Force)............................................................................................................将项名称与通配符匹配...............................................................................................................排除项 (-Exclude)......................................................................................................................混合使用 Get-ChildItem 参数.....................................................................................................直接对项进行操作.................................................................................................................................创建新项 (New-Item).....................................................................................................................为什么注册表值不属于项...............................................................................................................重命名现有项 (Rename-Item).......................................................................................................移动项 (Move-Item).......................................................................................................................复制项 (Copy-Item).......................................................................................................................删除项 (Remove-Item)..................................................................................................................执行项 (Invoke-Item).....................................................................................................................处理对象...............................................................................................................................................获取 WMI 对象 (Get-WmiObject)..........................................................................................................获取 WMI 对象 (Get-WmiObject)......................................................................................................列出 WMI 类..................................................................................................................................显示 WMI 类详细信息....................................................................................................................使用 Format Cmdlet 显示非默认的属性.....................................................................................创建 .NET 和 COM 对象 (New-Object).................................................................................................使用 New-Object 访问事件日志.....................................................................................................将构造函数与 New-Object 结合使用..........................................................................................在变量中存储对象......................................................................................................................使用 New-Object 访问远程事件日志..........................................................................................使用对象方法清除事件日志.......................................................................................................使用 New-Object 创建 COM 对象.................................................................................................使用 WScript.Shell 创建桌面快捷方式...........................................................................................使用 Windows PowerShell 中的 Internet Explorer........................................................................获取有关 .NET-Wrapped COM 对象的警告...................................................................................使用静态类和方法.................................................................................................................................使用 System.Environment 获取环境数据......................................................................................引用 System.Environment 静态类.............................................................................................显示 System.Environment 的静态属性......................................................................................使用 System.Math 进行数学运算..................................................................................................从管道中删除对象 (Where-Object).......................................................................................................使用 Where-Object 执行简单测试.................................................................................................根据对象属性进行筛选..................................................................................................................对多个对象重复同一任务 (ForEach-Object)..........................................................................................选择对象的各个部分 (Select-Object)....................................................................................................4对对象进行排序.....................................................................................................................................使用变量存储对象.................................................................................................................................创建变量........................................................................................................................................对变量进行操作.............................................................................................................................使用 Cmd.exe 变量.......................................................................................................................使用 Windows PowerShell 执行管理任务.............................................................................................管理本地进程........................................................................................................................................列出进程 (Get-Process)................................................................................................................停止进程 (Stop-Process)...............................................................................................................停止所有其他 Windows PowerShell 会话......................................................................................管理本地服务........................................................................................................................................列出服务........................................................................................................................................停止、启动、挂起和重新启动服务................................................................................................收集有关计算机的信息..........................................................................................................................列出桌面设置.................................................................................................................................列出 BIOS 信息.............................................................................................................................列出处理器信息.............................................................................................................................列出计算机制造商和型号...............................................................................................................列出已安装的修补程序..................................................................................................................列出操作系统版本信息..................................................................................................................列出本地用户和所有者..................................................................................................................获得可用磁盘空间.........................................................................................................................获得登录会话信息.........................................................................................................................获得登录到计算机的用户...............................................................................................................从计算机获得本地时间..................................................................................................................显示服务状态.................................................................................................................................处理软件安装........................................................................................................................................列出 Windows Installer 应用程序..................................................................................................列出所有可卸载的应用程序...........................................................................................................安装应用程序.................................................................................................................................删除应用程序.................................................................................................................................升级 Windows Installer 应用程序..................................................................................................更改计算机状态:锁定、注销、关闭和重新启动..................................................................................锁定计算机....................................................................................................................................注销当前会话.................................................................................................................................关闭或重新启动计算机..................................................................................................................处理打印机............................................................................................................................................列出打印机连接.............................................................................................................................添加网络打印机.............................................................................................................................设置默认打印机.............................................................................................................................删除打印机连接.............................................................................................................................执行网络任务........................................................................................................................................列出计算机的 IP 地址....................................................................................................................列出 IP 配置数据...........................................................................................................................对计算机执行 Ping 操作................................................................................................................检索网络适配器属性......................................................................................................................为网络适配器指定 DNS 域............................................................................................................执行 DHCP 配置任务.....................................................................................................................确定启用 DHCP 的适配器..........................................................................................................检索 DHCP 属性........................................................................................................................在每个适配器上启用 DHCP.......................................................................................................对特定适配器解除和续订 DHCP 租约........................................................................................对所有适配器解除和续订 DHCP 租约........................................................................................创建网络共享.................................................................................................................................删除网络共享.................................................................................................................................连接 Windows 可访问的网络驱动器..............................................................................................处理文件和文件夹.................................................................................................................................列出文件夹中的所有文件和文件夹................................................................................................复制文件和文件夹.........................................................................................................................创建文件和文件夹.........................................................................................................................删除文件夹中的所有文件和文件夹................................................................................................将本地文件夹映射为 Windows 可访问驱动器................................................................................将文本文件读入数组......................................................................................................................处理注册表项........................................................................................................................................列出注册表项的所有子项...............................................................................................................复制项...........................................................................................................................................创建项...........................................................................................................................................删除项...........................................................................................................................................删除特定项下的所有项..................................................................................................................处理注册表条目.....................................................................................................................................列出注册表条目.............................................................................................................................获取单个注册表条目......................................................................................................................创建新的注册表条目......................................................................................................................重命名注册表条目.........................................................................................................................6删除注册表条目.............................................................................................................................附录 1 - 兼容性别名..............................................................................................................................附录 2 - 创建自定义的 PowerShell 快捷方式........................................................................................Windows PowerShell 入门版权声明本文档仅供参考,Microsoft 在本文档中不提供任何明示或暗示的保证。
About the T utorialWindows Server 2012 codenamed Windows Server 8 is the most recent version of the operating system from Microsoft regarding server management, but not the last one which is Windows Server 2016. Officially it was released on August 1, 2012 and is just a commercial version as of now.Windows Server 2012 has four editions: Foundation, Essentials, Standard and Datacenter. Each one of them has their own limitations except the Datacenter version, which is also the most expensive one.This is an introductory tutorial that explains all the fundamentals of Windows Server 2012.AudienceThis tutorial has been designed for all those readers who want to learn the features of Windows Server 2012. It is especially going to be useful for all those professionals who are required to install and use this operating system to perform various duties in their respective organizations.PrerequisitesWe assume the readers of this tutorial have a practical experience of handling a Windows-based Servers. In addition, it is going to help if the readers have a basic knowledge of how to install and use an operating system.Disclaimer & CopyrightCopyright 2018 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher.We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or inthistutorial,******************************************T able of ContentsAbout the Tutorial (1)Audience (1)Prerequisites (1)Disclaimer & Copyright (1)Table of Contents (2)1.WINDOWS SERVER 2012 – OVERVIEW (5)Improvements in Windows Server 2012 (5)2.WINDOWS SERVER 2012 – INSTALLATION (8)System Requirements (8)3.WINDOWS SERVER 2012 – SERVER ROLES (15)4.WINDOWS SERVER 2012 − POWERSHELL (22)PowerShell ISE (24)PowerShell Basic Commands (27)5.WINDOWS SERVER 2012 − REMOTE MANAGEMENT (29)Adding a Server for Remote Management (30)6.WINDOWS SERVER 2012 − WINDOWS FIREWALL (33)How to Create a New Firewall Rule? (36)7.WINDOWS SERVER 2012 − REMOTE DESKTOP MANAGEMENT (45)8.WINDOWS SERVER 2012 − RESOURCE MON ITOR (49)9.WINDOWS SERVER 2012 − ACTIVE DIRECTORY (51)10.WINDOWS SERVER 2012 − DC ACCOUNTS (61)11.WINDOWS SERVER 2012 − FILE SYSTEM (65)12.WINDOWS SERVER 2012 − GROUP MANAGED SERVICE ACCOUNTS (67)13.WINDOWS SERVER 2012 − GROUP POLICY OVERVIEW (70)14.WINDOWS SERVER 2012 − DHCP ROLE (73)Post-deployment Configuration (79)Scope Implementation of DHCP (81)15.WINDOWS SERVER 2012 − DNS ROLE (91)16.WINDOWS SERVER 2012 − PRIMARY ZONES (96)17.WINDOWS SERVER 2012 − MANAGE RECORDS (100)18.WINDOWS SERV ER 2012 − IIS OVERVI EW (105)19.WINDOWS SERVER 2012 − IIS SECURITY (111)20.WINDOWS SERVER 2012 − HYPER-V (119)21.WINDOWS SERVER 2012 − ADVANCED CONFIGURATION (124)22.WINDOWS SERVER 2012 − CONFIGURE WSUS ROLE (130)23.WINDOWS SERVER 2012 – WSUS POLICIES & TUNING (134)24.WINDOWS SERVER 2012 − SHARING OF FILES (144)25.WINDOWS SERVER 2012 − FILE MANAGER (151)26.WINDOWS SERVER 2012 − PRINT SERVER (160)27.WINDOWS SERVER 2012 − EASY PRINTING (163)28.WINDOWS SERVER 2012 − CONFIGURE PRINT DRIVERS (166)29.WINDOWS SERVE R 2012 − NETWORK SER VICES (168)30.WINDOWS SERVER 2012 − BACKUP MANAGEMENT (176)Windows Server 2012 Windows Server 2012 codenamed Windows Server 8 is the most recent version of the operating system from Microsoft regarding server management. But it is not the last one, as the last one is Windows Server 2016. Officially it was released on August 1st, 2012 and is being sold as a commercial version only.Improvements in Windows Server 2012The major Improvements on this version are as follows:∙It is ready to be integrated with cloud systems and it still can maintain the classic features of local datacenters as a result Hyper-V Virtualization has new features Hyper-v replicas, it allows you to create virtual machines replications between clusters and storage systems.∙The Storage migration virtual disks can be moved to different physical storages, Virtual machine snapshots, virtual machines can be deleted from the Hyper-v and also from the virtual disks and it can be used directly without the need to shut down the virtual machine.∙The Core server installation easily switches to GUI installation without the need of reinstallation.∙The file server and storage service improvement is that it eliminates identical copies in the same volumes as such and saves space.∙The Storage pools and storage spaces allows you to group the hard disks to one or more storage pools then it allows to create virtual disks. It can add other disks to the storage pools and make available to the users without impacting them.∙The iSCSI Target Server can offer block storage to other servers and applications on the network using the iSCSI standard.∙Active Directory cloning can deploy additional domain controllers by cloning an existing virtual domain controller.Windows Server 2012 – OverviewThe Windows Server 2012 has four editions: Foundation, Essentials, Standard and Datacenter. Each one of them has their own limitation accept the Datacenter version which is also the most expensive one.The following table will show what is the right one for your business needs:For finding out the cost of licensing you can click on the following link:https:///en-us/server-cloud/products/windows-server-2012-r2/purchasing.aspxWindows Server 2012 – InstallationWindows Server 2012In this chapter, we will discuss regarding the requirements and prerequisites of the Windows Server 2012.System RequirementsAlthough most of the servers nowadays probably have the necessary requirements for Windows Server 2012. It will certainly be useful to know them in case you want to upgrade from an older system.The main requirements are:∙CPU socket minimum 1.4 GHz (64-bit processor) or faster for single core and Microsoft recommends is 3.1 GHz (64-bit processor) or faster multi-core.∙RAM memory minimum is 2GB, but Microsoft recommends 8GB.∙160 GB hard disk with a 60 GB system partition space in your hard disk.One important thing to note here is that the installation process itself will verify your computer hardware and let you know if it qualifies for a Windows Server 2012 installation. If not, then you will need to upgrade your hardware.InstallationThe following steps are to be adhered for the installation of Windows Server 2012.Step 1: We can download the evaluation ISO of Windows Server 2012 R2 from the following link:https:///en-us/evalcenter/evaluate-windows-server-2012-r2But you will need to sign in first with a Microsoft account like Hotmail for example in order to complete the download and the good thing is that the evaluation period will last for 180 days, so you will have enough time to know if it will be the right product for you or not.At the end, if you decide to buy the license of your Windows server 2012 R2. You can purchase it online via a Microsoft online store found in –/store/msusa/en_US/list/Windows-Server/categoryID.70676900?icid=BusinessR_Software_80_Windows_Server_112315 For the Enterprise solution, I would recommend to purchase it via a Microsoft partner that is found in your country.Step 2: After downloading the ISO of Microsoft, create a boot USB driver which can be created with the Microsoft tool called Windows USB/DVD Download Tool and can be downloaded from the following link:https:///en-us/download/windows-usb-dvd-download-toolAfter downloading the EXE file, open it and select the ISO file location and then click next like in the following screenshot, and wait up to the end when the Boot USB is created.Step 3: After completing the above given steps, plug-in the USB to the server and wait for a while till it loads the files. This will continue for about a couple of minutes as shown in the following screenshot.Step 4: After the files are loaded, you will see the screen of language settings of installation, keyboard, time and currency format. Generally, all the default ones are also good enough to start with. Click Next.Step 5: Click “Install now”.Step 6: Once you have clicked on Install Now, the setup will start and it will load all the files and the screen will look as shown in the following screenshot.Step 7: Wait until the files are loaded and then you will see the following screen. Let’s select Windows Server 2012 DataCenter Evaluation (Server with GUI) and click Next.Step 8:Click “I accept the license terms” and the n click on the Next button as shown in the following screenshot.Step 9:The following screen will appear. In “Driver Options” you can create a new partition, delete or format the Hard disk. After you have done this process then you can select the partition where the Windows server 2012 R2 will be installed in our case we have one partition. Once all this is done, then click on Next.Step 10:Let’s wait until this process finishes during this ti me and then the server will reboot.Step 11: Once the reboot is done the following screen will appear. Set the password for the server and then click on “Finish”.Step 12: It will take some minutes until the setup finishes completely.Step 13: Once all this is done, you have completed the installation process and the following screen will appear.CongratulationsWindows Server 2012Like the previous version, Windows Server 2012 has the following roles which can be used and in the subsequent chapter, we will see how to install and configure the most important ones.The following picture shows all the roles. A small reminder! – Roles and Features are the tools that you need to install or activate in order to complete your IT Administration duties, without their installation you cannot do anything.To add a role in the server we should adhere to the following steps:Windows Server 2012 – Server RolesStep 1: Click with the mouse on Server Manager which is found in the task bar as shown in the following screenshot.Step 2: After opening the “Server Manager”, click on the second option “Add roles and features”.Step 3: The following screen will appear, then you can Click on the Next button.Step 4:Select the Role-based or feature-based installation and then click on the Next button.In the next screen that appears, you will have the following two options:Option 1: Select a server from the server pool. This option is –if you want to install the services in the physical server like being done in the following screenshot.Option 2: Select a virtual Hard disk if you want to install the services in a virtual disk that can be somewhere in the network storage. Take a look at the following screenshot for better understanding.Step 5:The last step will be to check the service that you want to install, but in the upcoming chapters we will continue this setup for each and every important services.Windows Server 2012Windows PowerShell is a command-line shell and scripting language designed especially for system administration. It ’s analogue in Linux is called as Bash Scripting. Built on the .NET Framework, Windows PowerShell helps IT professionals to control and automate the administration of the Windows operating system and applications that run on Windows Server environment.Windows PowerShell commands, called cmdlets , let you manage the computers from the command line. Windows PowerShell providers let you access data stores, such as the Registry and Certificate Store, as easily as you access the file system.In addition, Windows PowerShell has a rich expression parser and a fully developed scripting language. So in simple words you can complete all the tasks that you do with GUI and much more.PowerShell Icon can be found in the task bar and in the start menu. Just by clicking on the icon, it will open.To open it, just click on the icon and then the following screen will open and it means that PowerShell is ready for you to work on.Windows Server 2012 − PowerShellThe latest version of PowerShell is 5.0 and to check what is installed in our server we type the following command –:$PSVersionTable as shown in the following screenshot and from the screen we also know that we have PSVersion 4.0To update with the latest version where it has more Cmdlets we have to download Windows Management Framework 5.0 from the following link –https:///en-us/download/details.aspx?id=50395 and install it.PowerShell ISEThe Windows PowerShell Integrated Scripting Environment (ISE) is a host application for Windows PowerShell. In Windows PowerShell ISE, you can run commands and write, test, and debug scripts in a single Windows-based graphic user interface with multiline editing, tab completion, syntax coloring, selective execution, context-sensitive help, and support for right-to-left languages.You can use menu items and keyboard shortcuts to perform many of the same tasks that you would perform in the Windows PowerShell console. For example, when you debug a script in the Windows PowerShell ISE, to set a line breakpoint in a script, right-click the line of code, and then click Toggle Breakpoint.To open it you just go to Start –Search and then Type –PowerShell as shown in the following screenshot.Then click on Windows PowerShell ISE. Or click on the downward Arrow as shown in the following screenshot.It will list all the applications installed on the server and then click on Windows PowerShell ISE.The following table will be open –It has three sections, which include –The PowerShell Console with number 1, then Scripting File number 2 and the third is the Command Module where you can find the module.End of ebook previewIf you liked what you saw…Buy it from our store @ https://。
(一)、PowerShell安装与配置重复数据删除功能安装:1、启动 Windows PowerShell。
在任务栏上,右键单击 Windows PowerShell 图标,然后单击“以管理员身份运行”。
运行以下 Windows PowerShell 命令:C:\> Import-Module ServerManagerC:\> Add-WindowsFeature -name FS-Data-DeduplicationC:\> Import-Module Deduplication启用重复数据删除功能:若要在卷上启用重复数据删除,请在服务器上运行以下 Windows PowerShell 命令。
卷 E 上启用了重复数据删除。
C:\> Enable-DedupVolume E:设置最少保留天数:设置文件进行重复数据删除前,应保留的最少天数。
C:\> Set-Dedupvolume E: -MinimumFileAgeDays 20如果将 MinimumFileAgeDays 设为 0,那么重复数据删除将处理所有文件,不论其留存时间有多久。
这适合于测试环境,在这种环境中你想要进行最大限度的重复数据删除。
但是,在生产环境中,最好是等待几天(默认为 3 天),因为在更改率减缓前,文件往往会在短时间内改变很多。
这允许对服务器资源进行最有效的使用。
清理日志存放地点:清理作业在位于此处的 Windows 事件日志中输出一个摘要报告:事件查看器\应用程序和服务日志\Microsoft\Windows\删除重复\清理数据清理作业:虽然重复数据删除默认值以每周一次(周六)的频率创建数据完整性清理作业,但你也可以使用以下命令,按照需要触发这种清理作业:C:\> Start-DedupJob E: –Type Scrubbing垃圾回收作业:重复数据删除包含了垃圾回收作业,来处理卷上已删除或已修改的数据,这样任何不再访问的数据区块都被清理。
PowerShell⼊门基础教程Windows PowerShell 是专为系统管理员设计的新 Windows 命令⾏外壳程序。
该外壳程序包括交互式提⽰和脚本环境,两者既可以独⽴使⽤也可以组合使⽤。
1、什么是交互式提⽰?答:交互式提⽰就像打开⼀个cmd窗⼝,在⾥⾯执⾏⼀个ping命令⼀样,它会动态的输⼊结果。
也可以像执⾏ftp命令⼀样,有⼀个上下⽂环境(Context),可以交互。
2、什么是脚本环境?答:就像写VBScript脚本⼀样,以⽂件形式把PowerShell的程序语句写下来,然后利⽤PowerShell的脚本环境来执⾏整个脚本⽂件。
顺便说⼀句,批处理也可以理解为⼀个脚本环境。
PowerShell脚本⽂件的扩展名为.ps1,语⾔⽀持⽤于循环、条件、流控制和变量赋值的语⾔结构。
Windows PowerShell 是专为系统管理员设计的新 Windows 命令⾏外壳程序。
该外壳程序包括交互式提⽰和脚本环境,两者既可以独⽴使⽤也可以组合使⽤。
解读:1、什么是交互式提⽰?答:交互式提⽰就像打开⼀个cmd窗⼝,在⾥⾯执⾏⼀个ping命令⼀样,它会动态的输⼊结果。
也可以像执⾏ftp命令⼀样,有⼀个上下⽂环境(Context),可以交互。
2、什么是脚本环境?答:就像写VBScript脚本⼀样,以⽂件形式把PowerShell的程序语句写下来,然后利⽤PowerShell的脚本环境来执⾏整个脚本⽂件。
顺便说⼀句,批处理也可以理解为⼀个脚本环境。
PowerShell脚本⽂件的扩展名为.ps1,语⾔⽀持⽤于循环、条件、流控制和变量赋值的语⾔结构。
与接受和返回⽂本的⼤多数外壳程序不同,Windows PowerShell 是在 .NET 公共语⾔运⾏时 (CLR) 和 .NET Framework 的基础上构建的,它接受和返回 .NET 对象。
环境中的这⼀根本更改带来了管理和配置 Windows 的全新⼯具和⽅法。
powershell用法PowerShell是一种用于自动化任务和管理Windows操作系统的命令行工具和脚本语言。
它具有强大的功能和灵活性,可以帮助管理员简化和加快日常管理任务的执行。
本文将介绍一些常见的PowerShell用法,帮助读者更好地理解和使用这个强大的工具。
我们来看一下PowerShell的基本用法。
在开始菜单中搜索PowerShell并打开,就可以进入PowerShell的命令行界面。
在这里,我们可以输入各种命令来执行不同的操作。
比如,我们可以使用"Get-Process"命令来列出当前正在运行的进程,使用"Get-Service"命令来列出系统中安装的服务,还可以使用"Get-EventLog"命令来查看系统事件日志。
这些命令都是PowerShell的内置命令,可以直接在命令行中使用。
除了内置命令,PowerShell还支持自定义函数和脚本。
我们可以使用"function"关键字定义一个函数,然后在命令行中直接调用。
函数可以接受参数,并根据参数执行不同的操作。
比如,我们可以定义一个函数来计算两个数的和:```function Add-Numbers($a, $b) {$sum = $a + $bWrite-Host "The sum is $sum"}```然后在命令行中调用这个函数:```Add-Numbers 2 3```这样就会输出" The sum is 5"。
除了函数,PowerShell还支持脚本的编写和执行。
我们可以使用任何文本编辑器创建一个ps1后缀的文件,并在其中编写PowerShell 脚本。
脚本可以包含多个命令和逻辑判断,可以帮助我们自动化执行一系列复杂的操作。
比如,我们可以编写一个脚本来批量重命名文件:```$files = Get-ChildItem -Path "C:\folder"foreach ($file in $files) {$newName = $.Replace("old", "new")Rename-Item -Path $file.FullName -NewName $newName}```这个脚本会获取指定文件夹下的所有文件,并将文件名中的"old"替换为"new",然后重命名文件。
Windows PowerShell 3.0The information contained in this document relates to a pre-release product which may be substantially modified before it is commeially released. Microsoft makes no warranties, express or implied with respect to the information presented here.Windows Server® 2012 is a great operating system for many servers and the devices that connect them—whether they are physical or virtual, on-premises or off-premisesIn the past, Microsoft® Windows® wasa great operating systemfor a single server and its devicesMulti-machine management Robust automation Standards-based management Unified experiencesWindows PowerShell 3.0 provides a comprehensive, resilient, and simple way to automate the management ofservers in your network•Windows PowerShell 1.0•100+ cmdlets and a powerful scripting language •Access to WMI objects on remote computers •Extensible through PSSnapins and managed code •Windows PowerShell 2.0•200+ cmdlets•PowerShell remoting (implicit and explicit) •Extensible through modules and PowerShell script •Background jobs•Integrated scripting environment•…Windows PowerShell today (version 2.0)Extended scripting functionality Remote management from anywhere223 core cmdlets and 456 total cmdlets in10 availablemodules•260 core cmdlets and more than 2,300 total cmdletsin 239 available modules •Management of all Windows roles and features•Native support for scheduled jobs•Robust Session Connectivity allows remote sessions to remain connected during network failures •Users can disconnect and reconnect sessions without losing state •Windows PowerShell Web Access •Windows PowerShell Workflows improve automation •Even easier to learn, use, and create new scripts•Updatable Help simplifies retrieval of the most recent Help documentationComprehensive, resilient, and simple automation from the command line:Windows PowerShell 3.0 in Windows Server 2012Features of Windows PowerShell 3.0Windows PowerShell Workflow.NET Framework 4 supportAdd-Member improvements Computer cmdletsCSV handling improvementsGet-ChildItem attributesGet-Command improvementsGet-Content -TailBetter history supportSecurity cmdlet fixesSelect-Object optimizationsSelect-String improvementsTee-Object -AppendDisconnected sessionsIdle timeout & server buffering control Invoke-Command -InDisconnectedSession Disconnected jobsSTA mode by defaultRun with PowerShell context menu Updated console font & branding Console host start perf improvements ETW logging and tracingModule loggingNew Group Policy settingsOutput redirection for all streams Dynamic types & formatsWord wrapDefault properties on custom objects Improved WMI object formatting Heterogeneous object formatting Updatable help systemMethod overload discoveryHelpUri attribute supportHelpFile property on FunctionInfoNew parser built on DLRSimplified Where and ForEachRemoting local variables via $usingArray syntax for scalarsCustom parameter value defaultsGeneric method invocationTypecasting deserialized objectsImproved method overload selectionNew objects from hash tablesOrdered hashtablesImproved typecasting for parameter values$PSScriptRoot and $PSCommandPathImproved module discovery & importNew module manifest keysPublic abstract syntax treePipeline paging APIsNested pipeline APIsRunspace pool cleanup APIPublic tab completionWinRT API supportObsolete cmdlet attributeVerb & Noun properties on FunctionInfoWeb & REST cmdletsJSON cmdletsControl Panel cmdletsUnblock-File cmdletCIM cmdlet authoring from WMI v2CIM .NET APIsCore CIM cmdletsRuntime script compilationEngine reliability improvementsBetter Get-ChildItem network perfCmdlet definition filesCertificate provider improvementsCredential support for FileSystem providerAlternate NTFS data stream supportMove-Item across drivesRemote module discovery & importRemote session autodisconnect & retryTransport options for remote sessionsRunAs and SharedHost supportScheduled jobsJob integration with Task SchedulerAlternate credential support for jobsSession configuration filesModule autoloadingCommand discovery improvementsSpecial character handlingLiteralPath support for core cmdletsImproved tab completionIntellisenseWindows Management Framework 3.0WinPE supportWindows RT supportWindows PowerShell Web AccessWindows PowerShell Web Services03Windows PowerShell 3.0 reduces the cost and complexity of management Windows PowerShell 3.0Rich management through many newcmdlets Robust Session Connectivity Disconnected SessionsWindows PowerShell Workflow Syntax simplificationWindows PowerShell Web Access Cmdlet discovery and module autoloadingWindows PowerShell Integrated ScriptingEnvironment(ISE) 3.0Script Sharing Scheduled jobs Updatable Help03Robust Session Connectivity: Remote sessions remain in a connected state duringtransient network glitches or failuresDisconnected Sessions: Persistent commands and jobs continue to run evenif the session is disconnectedDisconnected SessionsDisconnect-PSSession disconnects a session connection from a remote computerConnect-PSSession reestablishes a session connection with a remote computerReceive-PSSession resumes execution of a command on a remote session and retrieves the session output.; implicitly reconnects to session (without Connect-PSSession command)# Start a remote session, disconnect, and close Windows PowerShellPS C:\> $s=New-PSSession-ComputerNamesrv1-Name LongSessionPS C:\> $job=Invoke-Command$s { 1..10|% {echo "Long running job - part $_"; sleep 5} } -AsJobPS C:\> Disconnect-PSSession$sexit # Start Windows PowerShell on a different computerPS C:\> $s=Get-PSSession-ComputerName srv1-Name LongSessionPS C:\> $job=Receive-PSSession$s-Out JobPS C:\> Receive-Job$jobLong-running activities (in sequence or in parallel) that perform complex management tasks, such as multi-machine application provisioning Authored using WorkflowDesigner (XAML) or aWindows PowerShellscriptWorkflows survive systeminterruptions (reboots,network problems):suspend-job/resume-job,persist state, andmetadataWindows PowerShell Workflow:Windows PowerShell Web Access•New to Windows Server 2012 •Allows you to manage computersrunning Windows by usingWindows PowerShell within abrowserCmdlet discovery simplifies learning Windows PowerShell:Get-Command has been updated to find all cmdletsinstalled on the system Users can use the cmdlets immediately, because modules are imported automatically on first useTo find cmdlets, run Get-Command For example: Get-Command *-Net* To get the syntax of a cmdlet, use Get-Help For example: Get-Help NetAdapterSyntax simplification: Windows PowerShell 3.0 includes simplified,consistent syntax across all cmdletsSimplified scripting through Windows PowerShell Integrated Script Environment (ISE) 3.0: Show-Command pane lets users find and run cmdlets in a dialog boxSimplified scripting through Windows PowerShell ISE 3.0: IntelliSense provides context-sensitive command completion for cmdlet and script names; parameter names and enumerated values; and property and method namesSimplified scripting through Windows PowerShell ISE 3.0:Code examples add reusable text to scripts and commandsThe built-in code examples include templates for functions, parameters, and statements so users don’t have to rememberthe syntaxScript Sharing:A community-generated library of Windows PowerShell code snippets is available in ISE.Job Scheduling •Improves management automation •Schedule jobs for execution:–At a later time–According to a particular scheduleNew cmdlets in the PSScheduledJob module•Get-ScheduledJobOption •New-ScheduledJobOption •Set-ScheduledJobOption•Disable-ScheduledJob •Enable-ScheduledJob •Get-ScheduledJob •Register-ScheduledJob •Set-ScheduledJob •Unregister-ScheduledJob •Add-JobTrigger •Disable-JobTrigger •Enable-JobTrigger •Get-JobTrigger •New-JobTrigger •Remove-JobTrigger •Set-JobTriggerJobs execute based on triggersOnce DailyWeekly At Startup At LogonJobs example# Create a job trigger based on the desired schedule and register the job$trigger=New-JobTrigger-Daily-At4amRegister-ScheduledJob-Name MyScheduledJob-ScriptBlock { DoSomething } -Trigger $triggerGet-ScheduledJob# Once the trigger has fired and the job has run, you can work with it the same way you do regular background jobsImport-Module PSScheduledJob$j=Get-Job-Name MyScheduledJobReceive-Job$jProject Experience:批量新建虚机/b/taylorb/archive/2008/06/07/hyper-v-wmi-cloning-virtual-machines-using-import-export.aspxProject Experience:Orchestrator调用Windows Server 2012 Launch Day Session© 2012 Microsoft Corporation. All rights reserved. The information contained in this document relates to a pre-release product which may be substantially modified before it is commeially released.This pre-release product may not ever be commeially released. Microsoft makes no warranties, express or implied, with respect to the information presented here.。