RSS

Category Archives: Powershell

Powershell – Get Percentage of Pysical and Virtual Servers from your VMware and Cisco UCS combined for each location

In a previous blog post I’ve already shown this script that use PowerCLI to get the percentage of physical and virtual servers from your VMware environment for each Virtual Center server. This script however only took into account ESX hosts and VM’s in each Virtual Center server separately.

This means that:

  • The UCS blades weren’t taken into account as physical servers.
  • No percentage was being calculated for each physical location.

This new script automates determining for each location the number of physical and virtual servers in VMware vSphere and Cisco UCS.

PS: You can get more detailed information from the script, but it has been disabled using comments by default.

 

Tags: , , , , , , , , , , , , , , , , , , , , ,

PowerShell – Get UCS Blade Count

PowerShell has been adopted by many companies already including VMware and Cisco with its Unified Computing System (UCS).

This simple script will use the Cisco UCS PowerTool to connect to UCS and determine the blade count for each UCS server you’ve defined.

 

Tags: , , , , , , , ,

PowerShell – Get the percentage of physical and virtual servers from your VMware environment

With the current focus on Corporate Social Responsibility (CSR) including Green IT, it might be important to know what percentage of servers has been virtualized.

This script I made will use PowerCLI to get the percentage of physical and virtual servers from your VMware environment for each Virtual Center server. You can specify multiple Virtual Center servers if desired.

 

Tags: , , , , , , , , , , , , , , , , ,

PowerShell – Slipstream Office 2003 Updates

In yesterday’s post I described how you could extract Office 2003 updates. When they are extracted however, they still need to be slipstreamed into the package. I also created this script to automate the slipstreaming.

Basically for each extracted patch (.msp) file, it runs msiexec with the correct parameters. So if you have other msi packages that need multiple patch (.msp) files applied to it, you could use this script as a foundation as well.

 

Tags: , , , , , , , , , , ,

PowerShell – Extract Office 2003 Updates

Not so long ago I had to create a new Office 2003 Administrative Installation Point.

There were 2 choices:

  1. Use the default ISO and have WSUS handle patching after each install.
  2. Slipstream all available patches in the Office 2003 Administrative Installation Point.

Ofcourse option 2 is the best choice, because then the package will be the most secure from the moment the software is deployed. Also it saves bandwidth and time.

To slipstream updates into Office 2003, there are basically 4 steps:

  1. Extract the original Office 2003 files.
  2. Download the updates you want to slipstream.
  3. Extract the updates you want to slipstream.
  4. Slipstream the updates into the extracted Office 2003 files.

You can imagine that the older the source files are, the more updates there are to be slipstreamed. So it is best to use an ISO/CD of Office 2003 with the latest Service Pack.

Still if you have the latest Service Pack, you need to slipstream more than 20 updates. I personally don’t like these kind of manual tasks, so I created this script to do the extraction of the updates for me.

Ofcourse this script can be used to extract other kinds of updates as well..

 

Tags: , , , , , ,

PowerShell – Determine which Active Directory objects are protected from accidental deletion

In yesterday’s post I showed some commands to protect all or specific Active Directory objects from accidental deletion.

In some situations (by example preparing for a change) you might want to know which objects are protected from accidental deletion and which are not. Also when multiple people make changes in an Active Directory it might prove difficult to keep track of the changes.

To determine the protection status of AD objects, I use a script that checks the ACL of the AD Object. When Everyone is explicitly Denied access, it is protected from accidental deletion.

 

Tags: , , , , , , , , , , , ,

PowerShell – Protect Active Directory objects from accidental deletion

In a previous blog post I explained how to enable the Active Directory Recycle Bin which allows you to restore deleted active directory object.

But even though it’s great to be able to restore objects, it is even better to prevent accidental deletion. What accidental deletion basically does, is modify the permissions on an AD object to Deny Everyone so you won’t be able to delete it by accident.

More information about protection from accidental deletion can be found in “Preventing Unwanted/Accidental deletions and Restore deleted objects in Active Directory” and “Windows Server 2008 Protection from Accidental Deletion“.

In Windows Server 2012 with all the new cmdlets, it has become much easier to enable protection from accidental deletion.

By example, you could use these commands:

#Get-ADobject class names
get-adobject -filter * | select objectclass | group objectclass

#Protect specific AD object classes from accidental deletion
get-adobject -filter * | where{($_.ObjectClass -eq “container”) -or ($_.ObjectClass -eq “organizationalunit”) -or ($_.ObjectClass -eq “user”) -or ($_.ObjectClass -eq “group”) -or ($_.ObjectClass -eq “computer”)} | Set-ADObject -ProtectedFromAccidentalDeletion $true

#Protect all AD organizational units from accidental deletion
Get-ADOrganizationalUnit -filter * | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $true

#Protect all AD objects from accidental deletion
Get-ADobject -filter * | Set-ADObject -ProtectedFromAccidentalDeletion $true

 

Tags: , , , , , , , , , , , , , ,

PowerShell – Copy monthly reports to customer reporting folder

Currently report files for multiple customers are placed in a source folder monthly. These report files include the customer name and need to be uploaded a for each customer in a subfolder named “Backup Controle” of their own folder.

Notes:

  1. The customer’s root folder name can differ from the customer name used in the report files.
  2. The folder “Backup Controle” isn’t always located in the same relative location from the root folder

Example:

  • The source report files folder contains:
    • Backup Controle – Customer 1 – 12-2012.pdf
    • Backup Controle – Customer 2 – 12-2012.pdf
  • The customer’s root folder’s might be:
    • C:\Customersroot\Cust1
    • C:\Customersroot\Client2
  • The “Backup Controle” folder might be located at:
    • C:\Customersroot\Cust1\folder1\folder2\folder3\temp\folder4\Backup Controle
    • C:\Customersroot\Client2\folder1\folder2\Backup Controle

This action was performed manually at first using the SharePoint web interface to browse to each customer’s folder and upload the report. This is ofcourse not the type of work you want to do. Using the SharePoint WebDAV you can perform this using Explorer and drag and drop, which would make it a bit more bearable.

It would however be even better if it could be automated and that’s just what we did with this script. The script contains a function where you can define for each customer:

  1. Which name filter specifies the customer for the report name. B.e. : “Customer 1” or “Customer 2”
  2. What the name of the folder is for the customer’s root folder. B.e. : “Cust1” or “Client2”

The script will then recursively look inside the customer’s folder for a folder matching the “Backup Controle” folder and will copy the report to it (assuming the report is not already there).

In this example you would call the function like this:

  • Copy-FileMatchingFilterToCustomerFolder “Customer 1” “cust1”
  • Copy-FileMatchingFilterToCustomerFolder “Customer 2” “client2”

Note: It is assumed that there is only one folder named “Backup” Controle in the customer’s folder.

 
Leave a comment

Posted by on January 7, 2013 in ICT, Learning, Microsoft, Powershell, Windows

 

Tags: , , , , ,

PowerShell – Add websites to the Flash whitelist for Internet Explorer 10 (Metro – Modern UI)

[EDIT] 09-04-2013 : As described in my blog post, this script has become unnecessary for most people. This is because Microsoft to allow almost every Flash site by default. [EDIT]

[EDIT] 13-01-2013 : Apparently for Windows RT, the script doesn’t seem to be working yet. Unfortunately I have no Windows RT to troubleshoot and resolve the issue. [EDIT]

Windows 8 and Windows RT include support for Flash in Internet Explorer 10.

In Windows 8 there are however two version of Internet Explorer 10 that handle flash websites differently. First there’s Internet Explorer 10 Desktop, which is similar as the Internet Explorer you’ve been used to with previous versions of Windows. Then there’s also Internet Explorer 10 (non Desktop), which is the Internet Explorer in the new modern/Windows interface (Metro) that is full screen.

Internet Explorer 10 Desktop allows Flash for all websites. Internet Explorer 10 (Metro) only allows Flash for websites that have been whitelisted.

Especially for Windows tablets, Flash support can be a selling point because most other tablets don’t have Flash support. It is however confusing for regular consumers that not all their websites will work. By example a friend of mine who’s a hairdresser, uses http://www.kapperssite.nl to show her customers hair models and their haircuts. The site is however completely in Flash and that it is not working by default is very annoying.

The websites that have been whitelisted are defined in your local appdate folder. By example: “C:\Users\Bjorn\AppData\Local\Microsoft\Internet Explorer\IECompatData\iecompatdata.xml”. This file also contains information about websites and which compatibility mode should be used for each. The segment between <flash> and </flash> contains the websites that have been whitelisted for flash. You can manually modify this file as described here: http://forum.xda-developers.com/showthread.php?t=1961793

Basic steps include:
  1. Modifying the iecompatdata.xml to add the websites you want to whitelist for Flash. Wildcards don’t work unfortunately.
  2. Open Internet Explorer 10 Desktop, press ALT, Tools, “Compatibility View setting”. Then Disable “Download updated compatibility lists from Microsoft”. This way Microsoft won’t overwrite the updates you’ve made in step 1.
  3. Delete the IE10 browser history. The disadvantage of this method however is, that you won’t be taking advantage of future compatibility updates because you’ve disabled the update functionality. Leaving it enabled however means that you you would have to keep re-adding sites you want to whitelist for Flash.

As a workaround, I’ve created this script that will automatically perform these tasks:

  1. Disable “Download updated compatibility lists from Microsoft”
  2. Close all internet explorer processes.
  3. Download the latest iecompatdata.xml to the appropriate folder. Currently the latest version is: https://iecvlist.microsoft.com/ie10/201206/iecompatviewlist.xml
    The script however will dynamically look for the latest versions by modifying the date in the url.
  4. Combine the data from the latest iecompatdata.xml with websites you want to whitelist for Flash (specified in “C:\Users\Bjorn\AppData\Local\Microsoft\Internet Explorer\IECompatData\flashsitestoadd.txt).
  5. Backup the original iecompatdata.xml and store the modified iecompatdata.xml
  6. Clear the Internet Explorer browsing history.

Because automatic downloading of updated compatibility lists has been disabled, I advise to schedule the script to run on a regular basis (by example monthly). For instructions read this blog post: http://blogs.technet.com/b/heyscriptingguy/archive/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script.aspx Keep in mind that this will clear your Internet Explorer browsing history though.

 

Tags: , , , , , , , , , , ,

PowerShell – Enable Active Directory Recycle Bin

Many companies and people in the past have encountered where they lost users, groups or other resources from Active Directory either by disaster or human error. Since Windows Server 2008 R2, you can use the Active Directory Recycle Bin to easily recover from this.

The AD Recycle Bin features requires a forest functional level of Server 2008 R2 or higher and is disabled by default. Also, once it has been enabled it cannot be disabled.

With Windows Server 2008 R2 you could only enable the AD Recycle Bin using Windows PowerShell and you could also only restore objects using CLI. With Windows Server 2012 you can both enable and restore very easily from the GUI using Active Directory Administrative Center (ADAC).

The script can be found here.

The script basically performs the following steps:

  1. Determine the current forest.
  2. Use parts of the current forest name to dynamically generate a command that is appropriate for every environment to enable the Active Directory Recycle Bin Feature.
  3. If the Active Directory Recycle Bin Feature hasn’t been enabled yet, enable it.

Even though it has become very easy to do using the GUI in Windows Server 2012, automating is Always better. Therefore I also added it to the script I used in: Home LAB Setup guide – 04 Configuring Server 2012 VM as DC with DNS and DHCP using PowerShell

 

Tags: , , , , , , , , ,