OneScript Team Blog

A world of automation script samples based on IT Pros' real-world tasks
  • A Forming Repository of Script Samples for Automating Windows Server 2012 and Windows 8

    Today marks the General Availability of Windows Server 2012, a special day in what will be a big launch year for Microsoft and our customers and partners worldwide.

    Compared with Windows Server 2008/R2 that provides about 230 cmdlets, Windows Server 2012 beats that by a factor of over 10 shipping ~ 2,430 cmdlets.  You can automate almost every aspect of the server.   The new PowerShell 3.0, like Windows Server 2012, has a ton of new features.  In this automation script-centric move, Microsoft All-In-One Script Framework (AIOSF) is ready to support IT Pros with many new services and offerings coming this year.  We sincerely hope that the IT community will benefit from the effort.

    Here is the first one among our new services and offerings: 

    The team is preparing a large set of Windows 8 / Windows Server 2012 script samples based on frequently asked IT tasks that we collect in TechNet forums and support calls to Microsoft.   Because the script topics come from frequently asked IT tasks, we hope that these script samples can be helpful to many IT Pros worldwide.   With the General Availability of Windows Server 2012, we release the first three Windows Server 2012 / Windows 8 script samples today. 

     

    Get Network Adapter Properties in Windows Server 2012 and Windows 8 (PowerShell)

    http://gallery.technet.microsoft.com/scriptcenter/Get-Network-Adapter-37c5a913

    Description: This script could be used to get network adapter properties and advanced properties in Windows Server 2012 and Windows 8. It combines the outputs of Get-NetAdapter and Get-NetAdapterAdvancedProperty. It can generate a report of network adapter configuration settings.

    Use Scenarios: In a real world, IT Administrators are required to check the configuration of network adapters after the deployment of new servers. One typical example is the duplex setting of network adapters. Also, IT administrators need to maintain a server list which contains network adapter configuration settings in a regular basis. Before Windows Server 2012, IT administrators often feel difficulties to handle these tasks.

    Acknowledgement: Thanks Greg Gu from AIOSF for collecting this script topic, and writing the script sample.  Thanks James Adams (Microsoft Premier Field Engineer) for reviewing the script sample and ensuring its quality.

     

    How to batch create virtual machines in Windows Server 2012 (PowerShell)

    http://gallery.technet.microsoft.com/scriptcenter/How-to-batch-create-9efd1811

    Description: This PowerShell Script illustrates how to batch create multiple virtual machines based on comma delimited file by using PowerShell 3.0 in Windows Server 2012.

    Use Scenarios: IT admin requires to batch creating virtual machines in Windows Server 2012, although they can use few commands due to the lack of programming knowledge. Although it’s a set of Hyper-V command-lets within Windows PowerShell, IT Admins are reluctant to use them except simple a command which is widely used.

    Acknowledgement: Thanks Anders Wang from AIOSF for collecting this script topic and writing the script sample.  Thanks Christopher Norris for reviewing the script sample and ensuring its quality before publishing.

     

    Remove Windows Store Apps in Windows 8 (PowerShell)

    http://gallery.technet.microsoft.com/scriptcenter/Remove-Windows-Store-Apps-a00ef4a4

    Description: This script can be used to remove multiple Windows Store Apps from a user account in Windows 8. It provides a list of installed Windows Store applications. You can specify the application IDs, and remove them all at once.

    Use Scenarios:

    1. In Windows 8, you can remove a single Windows Store App by right-clicking the tile in the Start menu and choosing the uninstall command.  However, no command is provided for removing multiple Windows Store Apps all at once. If you want to do so, you can use this script sample.

    2. Sometimes Windows Store Apps may crash in Windows 8.  Even though you can successfully uninstall and reinstall the App, the application may still crash after the reinstallation.  In this situation, you can use this example script to remove these Windows Store Apps cleanly.

    Acknowledgement: Thanks Edward Qi from AIOSF for collecting the script idea and composing the script sample.  Thanks James Adams (Microsoft Premier Field Engineer) for reviewing the script sample and ensuring its quality.

     

    This is just the beginning, and more and more script samples are coming.  You can follow our blog (http://blogs.technet.com/b/onescript) to get the latest customer-driven script samples for Windows Server 2012 and Windows 8.

  • You vote it; we write it! - Microsoft All-In-One Script Framework

    youvoteitwewriteit

    Microsoft All-In-One Script Framework is an on-going effort in which the Microsoft team writes PowerShell/VBS/T-SQL script samples for IT Pros based on their feedback.   The feedback is collected by the team from Microsoft's TechNet forums, Microsoft’s phone support incidents, as well as other social media and communities based on frequently asked IT tasks.   If an IT task is, for example, asked in more than two TechNet forum threads, the team will consider the task as a potential script topic, and providing a script sample to demonstrate how to ease the task with automation scripts. 

    Since the Microsoft All-In-One Script Framework was launched in August,  the team has collected over 350 script topics.  More than 50 of these script ideas have been turned into the actual script samples published on TechNet Script Repository.   In order to better prioritize the script topics and hear more from customers, All-In-One Script Framework launches the “You vote it; We write it” program today in partnership with TechNet Script Repository.   In this program, the team is going to publicly post the collected script topics.  The IT community can vote for these script topics. The higher the topic is voted, the higher priority will the team offer to write and publish the script sample.  

    Every week, the team will post a batch of script topics for the IT community to vote.   You can follow it by subscribing to the "YouVoteWeWrite” RSS feed or visiting this page.  You simply vote for your beloved or wanted script topics.   The All-In-One Script Framework team will write the script sample for you, free of charge.

     

    Here is the first batch of script topics for you to vote!

     

    Windows 8 and Windows Server 2012 Script Topics

    How to get the current automatic theme color in Windows 8?

    Script to Monitor Scheduled Tasks on a server

     

    Office 365 Script Topics

    O365: Set Calendar Permission in Office 365 Exchange Online

    O365: Set OWA Signature in Office 365 Exchange Online

    O365: Add Birthday or Anniversary Reminder in Office 365 Exchange Online

    O365: Export Distribution Group Members in Office 365 Exchange Online

    O365: Remove Duplicated Contacts in Office 365 Exchange Online

    O365: Operate Connected Email Account

  • Windows 8 and Windows Server 2012 How-do-I Script Sample Videos on Channel 9

    Microsoft All-In-One Script Framework is featured by script samples that address frequently asked IT requests in TechNet forums and Microsoft Support.  In order to give IT Pros an easier, quicker and more enjoyable learning experience of our script samples,  the team is partnering with Microsoft DPE Julie-Anne Arsenault, Chris Caldwell and Jana Butler, and a video creation team lead by Felix Wu and Jianhua Dong, to create 5 to 10 mins’ short HD demonstration videos for selected Windows 8 and Windows Server 2012 script samples.  Thanks to the DPEs’ support, the videos are published on the well-known Microsoft Channel 9 community with a new homepage aggregating all our videos. 

    http://channel9.msdn.com/Blogs/OneScript

    image

     

    After watching the video, you can easily download and learn more details of the script sample by clicking its “Sample Download” link on the page.   Here is one of the videos.

     

    This is a continuous effort.  Microsoft All-In-One Script Framework and the partner teams are committed to this.  You can subscribe to the videos by clicking the “Subscribe to this blog” button in http://channel9.msdn.com/Blogs/OneScript.  We hope to hear your feedback and suggestions and continuously improve the videos to better serve our customers.

    image

  • Microsoft All-In-One Script Framework Sample Release on January 16th

    We have released 130 script samples since we released the 100th sample last month!  Our sample repository is growing quickly every month.  The team closely monitors the entire TechNet forum platform, and customers’ support calls to Microsoft, and create automation script to ease those frequently asked IT tasks.   We wish that the samples will save your time.

    In this blog, we introduce 11 new samples, including 4 Windows 8 script samples; 7 Office 365 scripts sample. The scripts are written for solving frequently asked IT tasks that our team observed in the TechNet forums and Microsoft Support Incidents.  Many customers are asking about these IT scenarios.

     

    Windows 8 Script Samples

    image

    Script to create a custom Refresh Image in Windows 8

    Download: SetRefreshImage.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Script-to-create-a-custom-a6e8b4e8 

    Description: This PowerShell Script shows how to create custom refresh image.

    User Scenarios: Windows refresh feature doesn’t allow you to create custom refresh points like Windows System Restore does. Instead, Refresh creates a Windows Installer Image to help it restore settings to default state. This script can do it.

    Acknowledgement: Thanks Anders Wang (one of the PowerShell MVPs in All-In-One Script Framework Team) for the script idea and composing the script sample. 

     

    Change the Number of Tile Rows on the Start screen in Windows 8 (VBScript)

    Download: ChangeNumberOfAppsTileRows (VBScript).zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Change-the-Number-of-Tile-cd9bcc1a

    Description: This VBScript shows how to change the number of tile rows on the Start screen in Windows 8.

    User Scenarios: By default, the number of rows for the tiles is fully dependent on the screen resolution or window size that fits on your Windows Screen. But sometimes the user wants to display a specific number of rows of tiles on the Start Screen that is not dependent on the screen size.

    Acknowledgement: Thanks Anders Wang (PowerShell MVP) for the script idea and composing the script sample. 

     

    Delete invalid shortcut on the Start screen in Windows 8 (VBScript)

    Download: RemoveInvaildShortcutOnStartScreen(VBScript).zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Delete-invalid-apps-bfb4b0c3

    Description: This VBS Script shows how to remove invalid shortcut on the Start screen.

    User Scenarios: Sometimes when you uninstall software on your computer, even though the software is uninstalled successfully, it leaves some shortcuts that were created behind in your computer. These shortcuts do not work as the related softwares are uninstalled. Perhaps you move a file or a folder to a different location, the shortcut to that file or folder becomes invalid as it still points to the earlier location.

    Acknowledgement: Thanks Chao Ma for the script idea and composing the script sample. 

     

    Change background color of Windows 8 Start screen (VBScript)

    Download: ChangeWin8StartScreenBackColor.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Change-background-color-of-f70f4c41

    Description:  This sample shows how to change background color of a Windows 8 Start screen by using VBScript.

    User Scenarios: IT administrators can use this script to adjust the background color of a Windows 8 Start screen for a group of computers to keep user experience consistent.

    image

    Acknowledgement: Thanks Huilin Zhu for collecting the script topic from frequently asked questions in TechNet Windows 8 forums.  Zhi-Yi Guo wrote the script sample and Alan Olegario (PFE) reviewed it.

     

    Office 365 Script Samples

    image

    Send Emails until a Designated Time in Office 365 Exchange Online

    Download: SendOSCEXOMailMessage.zip
    Details:  http://gallery.technet.microsoft.com/scriptcenter/Send-Emails-until-a-9cee20cf

    Description:  This script can send an email message with Office 365 Exchange Online. Also this script allows you to delay sending an email message.

    User Scenarios: Microsoft Outlook has a feature that enables you to delay sending email messages. However, this feature is not available in the Outlook Web App (OWA). Therefore, in order to delay sending email messages for some business needs, you must find a workaround.

    Acknowledgement: Thanks Greg Gu (one of the PowerShell MVPs in All-In-One Script Framework) for the script idea and composing the script sample.

     

    Export Email Messages from OWA in Office 365 Exchange Online

    Download: ExportOSCEXOEmailMessage.zip
    Details:  http://gallery.technet.microsoft.com/scriptcenter/Export-Email-Messages-from-1419bbe9

    Description:  This script can export email messages from Outlook Web App to a specific folder. These email messages will be saved in .eml format. You need to find the email messages by using search folder.

    User Scenarios: Microsoft Outlook allows you to export email messages very easily. However, this feature is not available in the Outlook Web App (OWA). Therefore, in order to export email messages from OWA, you must find a workaround.

    Acknowledgement: Thanks Greg Gu (one of the PowerShell MVPs in All-In-One Script Framework) for the script idea and composing the script sample.

     

    Set Email Signatures in Office 365 Exchange Online

    Download: SetOSCEXOEmailSignature.zip
    Details:  http://gallery.technet.microsoft.com/scriptcenter/Set-Email-Signatures-in-792587f5 

    Description:  This script can set email signatures in Office 365 Exchange Online. You can change text signature and HTML signature.

    User Scenarios: Microsoft Outlook enables you to change email signatures very easily. However, this feature is difficult to use in Outlook Web App (OWA). For example, it may be difficult to insert images as signatures. Therefore, in order to set email signatures in OWA, you must find a workaround.

    Acknowledgement: Thanks Greg Gu for the script idea and composing the script sample.

     

    Connect to Office 365 Exchange Online with Prerequisites Verification

    Download: ConnectOffice365.zip
    Details:  http://gallery.technet.microsoft.com/scriptcenter/Connect-to-Office-365-dd471880 

    Description:  This script establishes a connection to Office 365 Exchange Online. Before establishing a connection, it checks the prerequisites that required by Office 365 Exchange Online.

    User Scenarios: Nowadays, Office 365 administrators are required to remember a long command to establish a connection to Office 365 Exchange Online. It’s not easy to remember all the parameters clearly. It’s better to save that command in a Windows PowerShell script. Additionally, it’s worth to check all the prerequisites to help Office 365 administrators to troubleshoot the connection issues.

    Acknowledgement: Thanks Greg Gu for the script idea and composing the script sample.

     

    Set Calendar Permission in Office 365 Exchange Online

    Download: SetOSCEXOCalendarFolderPermission.zip
    Details:  http://gallery.technet.microsoft.com/scriptcenter/Set-Calendar-Permission-in-ad7cd4e6

    Description:  This script can set calendar permission in Office 365 Exchange Online. You can set permission, grant permission and revoke permission on one or multiple calendar folders by using this script.

    User Scenarios: Currently, Add-MailboxFolderPermission only accepts single ID as the value of Identity parameter. It requires user to provide a full folder path, for example, "userid\Calendar\Calendar 01". It's inconvenient if you want to set permission on two or more calendar folders.

    Acknowledgement: Thanks Greg Gu for the script idea and composing the script sample.

     

    Retrieve Mailbox Folder and Subfolder Size in Office 365 Exchange Online

    Download: GetOSCEXOMailboxFolderSize.zip
    Details:  http://gallery.technet.microsoft.com/scriptcenter/Retrieve-Mailbox-Folder-227e7566 

    Description:  This script can retrieve mailbox folder and subfolder size in Office 365 Exchange Online.

    User Scenarios:

    Most of you manage your mailbox by using folders. These folders are named with year or other name conventions. When the mailbox is almost full, you will try to archive or delete old email messages. But you found that it’s inconvenient to check the size of each folder in Outlook Web App (OWA). So you are trying to find a workaround to mitigate this problem.

    Although, Office 365 administrators can use Get-MailboxFolderStatistics to help helpdesks to check the folder size. It's better to provide a script to reduce the support calls to these administrators in one company.

    Acknowledgement: Thanks Greg Gu for the script idea and composing the script sample.

     

    Bulk import the user information from CSV file

    Download: ImportUsersFromCSVFile.zip
    Details:  http://gallery.technet.microsoft.com/scriptcenter/Bulk-import-the-user-568abc5f

    Description:  This script can be used by an Office365 administrator to batch add user information from a CSV file.

    User Scenarios: Sometimes an Office365 administrator must add many users to Microsoft Office365. For example, when an organization first uses Office365, they must import all members to the system.

    Acknowledgement: Thanks Tony Zhang for the script idea and composing the script sample.  Thank Mauricio Tamayo Ortega (Senior Consultant at Microsoft) for reviewing the script sample.

  • Microsoft All-In-One Script Framework Sample Release on March 25th

    Are you ready for another wave of script samples?  Here are 13 new script samples for Windows, SharePoint and IE.  As always, the script samples are based on frequently asked IT tasks that we collected in TechNet forums. 

     

    Windows and Windows 8 Script Samples

    image

    Script to refresh Windows 8

    Download: RefreshWindows8.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Script-to-refresh-Windows-eca1e59a

    Description: This PowerShell Script shows how to create custom refresh image of Windows 8.

    User Scenarios: Windows Refresh gives you a quick and easy way to start with a clean slate while also maintaining your apps, data, Windows settings, and user profile.

     

    How to Delete the "Windows.old" Folder in Windows 8 (PowerShell)

    Download: DeleteWindowsOld.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/How-to-Delete-the-912d772b

    Description: This PowerShell script shows how to delete the "Windows.old" Folder in Windows 8.

    User Scenarios: When you performed a refresh of Windows 8, upgrade to Windows 8 or a custom install of Windows 8 without formatting the drive for a clean stall and selected to install Windows 8 on the same partition of the previous Windows installation, then you may have a "C:\Windows.old" folder left over in your new installation. It contains a copy of the previous Windows 8 installation, and can be quite large in size. If users are sure that they don't need this folder any more, they can try to use a script to delete the folder.

     

    Script to display the deleted objects in Active Directory (PowerShell)

    Download: DisplayDeletedADObjects.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Script-to-display-the-c995a5f6

    Description: This PowerShell script sample can display the deleted objects from the Active Directory.

    User Scenarios: Accidental deletion of Active Directory objects is a common occurrence for users of ADDS and ADLDS. This script can display the deleted objects from the Active Directory Recycle Bin.

     

    Script to add an item to Startup in Windows 8 (VBScript)

    Download: AddItemToStartup (VBScript).zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Script-to-add-an-item-to-2b99b14f 

    image

    Description: This VBScript sample shows how to add an item to the Startup in Windows 8.

    User Scenarios: Sometimes, users want programs to start when your system starts. Usually, you can add items to the startup folder. In Windows 8, adding items to Startup requires additional work. This script can resolve this problem.

     

    Check if disk partitions are 4KB aligned using PowerShell

    Download: Check4kAligned.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Check-if-disk-partitions-bb5b3eca

    Description: This script can be used to check if users' disk partitions are right 4kb alignment. Over the next few years, the data storage industry will be transitioning the physical format of hard disk drives from 512-byte sectors to 4,096-byte sectors (also known as 4K or 4KB sectors). This transition is driven by several factors. These include increases in storage density and reliability.  Many customers need to know if their disk partitions have non-4kb alignment issue which will cause incompatibility issues with existing software (including operating systems and applications).

    User Scenarios: We can use Test-OSC4kAligned function to check if user’s disk partitions are right 4kb alignment.

     

    Script to fix issues of Event ID 4107 and Event ID 11 (PowerShell)

    Download: BulkFixIssuesOfEventID4107AndEventID11.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Script-to-fix-issues-of-a5f6f91a

    Description: This sample can help the enterprise administrator to bulk fix the issue “Event ID 4107 or Event ID 11 is logged in the Application log in Windows and in Windows Server “ on all the client computers which have these issues in the enterprise’s  domain.

    User Scenarios: Event ID 4107 and Event ID 11 error occurs because the Microsoft Certificate Trust List Publisher certificate expired. A copy of the CTL with an expired signing certificate exists in the CryptnetUrlCache folder. To bulk resolve these issues, you can use this script to list all the expired certificates in the specific computer and remove all the files in the CryptnetUrlCache folder.

     

    Script to list the cluster servers (PowerShell)

    Download: ExportServersInCluster.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Script-to-list-the-cluster-cbab4d4b

    Description: This script will demo how to list the servers in one or more Windows clusters.

    User Scenarios: Sometimes, IT pro need to list all servers in the specified cluster(s).This script is to accomplish it.

     

    Script to disable "turn off this device to save power" for NIC Power Management

    Download: DisableNetworkAdapterPnPCapabilities(VBS).zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Insert-pictures-in-a-eb23b3a9

    Description: This VBS Script illustrates how to disable "turn off this device to save power" feature in Power Management.

    User Scenarios: Many users want to disable the option in network device called: Allow the computer turn off this device to save power. Now, this script can help users to disable "turn off this device to save power" feature in Power Management of all physical network adapters.

     

    SharePoint Script Samples

    image

     

    SPProfileDump

    Download: SPProfileDump.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/SPProfileDump-77f87a72

    Description: This script enumerates through the user profile manager for a given site collection and would extract information about all profiles from the profile store.

    User Scenarios: In SharePoint, we come across issues with profiles not being consistently updated with property values after an import operation. There could be numerous reasons for this; albeit a change in the import connection or the inability to reach and fetch information from a designated Directory server. Besides, the Central Admin UI doesn’t present a holistic view of all user profiles; neither is there an easier way to navigate through hundreds of profiles within the UI.

    SPProfileDump would extract all profile information to a comma delimited (SPProfileDump.CSV) file. Additionally, it would also create a SPProfileProperties.TXT file that would contain the very basics of each profile property. You can open the SPProfileDump.CSV file in a tool like Excel and use filtering to view data the way you want. For example, find how many profiles have come through a specific OU or per say, how many users do not have a valid PictureURL.

     

    How to remove users from a site that have a specific permission level

    Download: RemoveSPsiteUsers.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/How-to-remove-users-from-a-d792858b

    Description: This PowerShell script shows how to remove users from a site that have a specified permission level.

    User Scenarios: You cannot remove users from a site by using the UI and it is difficult to find all users that have a specific permission level.

     

    Complete the Reporting Services with SharePoint Integration configuration

    Download: IntegrateSSRSToSharePoint.zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Complete-the-Reporting-0971816b

    Description: This Windows PowerShell script achieves the same function as we to complete configure the Reporting Services integrate to SharePoint in SharePoint Central Administration. This script applies to SQL Server Reporting Services 2008 R2 or SQL Server Reporting Services 2008 integrate to SharePoint 2010.

    User Scenarios: When we need to configure SQL Server Reporting Services in SharePoint integrated mode, after installed and configured both SQL Server Reporting Services side and SharePoint side, in traditional way, we need to bind the report server URL and set authentication type in the SharePoint Central Administration.  Actually, we can also easily set these steps by using script. It is suitable for bellowing two conditions:

    • Never integrated any SQL Server Reporting Services to this SharePoint.
    • Had ever integrated SQL Server Reporting Services to this SharePoint, need to integrate one new SQL Server Reporting Services to this SharePoint.  

     

    Internet Explorer Script Samples

    image

    Setting Tab Process Growth for Internet Explorer (PowerShell)

    Download: SettingIETabProcessGrowth(PowerShell).zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Setting-Tab-Process-Growth-5e52fe62

    Description: This sample can help you to operate the “TabProcGrowth” registry entry to set Tab Process Growth(Sets the rate at which IE creates New Tab processes) for Internet Explorer 8 or later.  It shows how to get and set Tab Process Growth setting for the Internet Explorer installed on your computer by using PowerShell script.

    User Scenarios: If you have been using IE7, you are probably used to all your tabs opening under the same iexplore.exe process. The only exception is if you are on a Windows Vista machine and you are moving from Protected to Unprotected mode. Internet Explorer 8 or later had a big makeover in this area. You will now notice that new tabs typically open in a new process.  By default,  IE8 will start with two instances of iexplore.exe (one for the Frame, one for the tab) and grows the number of tab processes as needed based on the amount of available RAM, the number of tabs, the integrity levels for tabs, and the number of distinct IE sessions .

     

    Script to remove Internet Explorer in Windows 7 (PowerShell)

    Download: RemoveInternetExplorer (PowerShell).zip
    Details: http://gallery.technet.microsoft.com/scriptcenter/Script-to-remove-Internet-e8327b13 

    Description: This PowerShell script demo shows how to remove Internet Explorer in Windows 7.

    User Scenarios: In some situations, customers need to uninstall Internet Explorer 9 to fix crash issue, but they cannot manually uninstall Internet Explorer successfully sometimes.

   Script of the Day