Friday, September 5, 2014

AWS - Auto schedule EC2 instance to start/stop

In order to reduce costs of running test and dev EC2 instances at Amazon I've created a simple script that will run and start or stop an instance based on a schedule.  This script is a PowerShell script that relies on the AWS modules to be installed  ("Import-Module AWSPowerShell")  Refer to the link to Configure PowerShell for AWS  (FYI - configure your default profile using AWS access keys as required)

The script is looking for a tag, 'RunningSchedule' and parsing the value that is set within, which is in a format similar to a cron like style using 24 hour clock : H:H:D or H:H:D-D  (I didn’t include a minutes field)

First 'H' = Start time Hour
Second 'H'  =  Stop time Hour
'D' is for day(s) to run, 1 = Monday, 2=Tues, etc.    So if you want it to run Mon-Fri, enter 1-5
To disable the schedule completely, use ‘Disabled’ for the value.

Example, to have the server start at 8am, stop at 5pm, and run Mon-Fri use:   8:17:1-5
To have the server run from 10am to 3pm on Wed use: 10:15:3

The script will then either start or stop the server based on the schedule.
It will then send an email with the servers listed that were either started or stopped.

To schedule the script itself, I configured a scheduled task in Windows on a server.  Simply run a program "Powershell", path is  'C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe'
Include the optional arguments for the path to your script:  'C:\Scripts\AWS-schedule-start-stop-instances.ps1'


Here is the script:





Wednesday, January 15, 2014

Disk is write protected

Have you received the error "The disk is write protected"


I've come across this error when cloning a volume snapshot from our Equallogic SAN.  To overcome this issue and allow the drive to be usable again you must clear the readonly attribute of the disk.

1. Open a Command prompt by clicking Start, typing command, and clicking Command Prompt.
2. Type diskpart and press Enter.
3. Type list volume and press Enter.
4. Type select volume #, where # is the number of the drive that's giving you the "write-protected" error
5. Type attributes volume clear readonly and press Enter.
6. Type exit and press Enter.

Friday, December 20, 2013

Trust relationship failed


Run this command:
Reset-ComputerMachinePassword -Server DC01 -Credential Domain01\Admin01

Wednesday, December 11, 2013

Recipient isn't the expected type

Set-Mailbox fails, update "Send on behalf" exchange 2010, recipient isn't the expected type.

Issue:

When update "sent on behalf", you may face error "recipient isn't the expected type"

Cause:
"Send On Behalf" access has not been removed while disabling the mailbox, they accounts are still pointing to shared mailbox, it usually happens with migrated exchange.

Solution:

Go to AD Users & Groups
Select email account having problem
Click properties and select Attribute Editor
select PUBLIC DELEGATES and remove the mailbox account you seen in the error.

Saturday, August 10, 2013

Error message when you try to set an IP address on a network adapter

This error often occurs when cloning/copying virtual machines. You may have come across this error:

The IP address XXX.XXX.XXX.XXX you have entered for this network adapter is already assigned to another adapter Name of adapter. Name of adapter is hidden from the network and Dial-up Connections folder because it is not physically in the computer or is a legacy adapter that is not working. If the same address is assigned to both adapters and they become active, only one of them will use this address. This may result in incorrect system configuration. Do you want to enter a different IP address for this adapter in the list of IP addresses in the advanced dialog box?

There's a simple fix to this and requires following these steps from the command prompt.
  1. Type set devmgr_show_nonpresent_devices=1, and then press Enter.
  2. Type Start DEVMGMT.MSC, and then press Enter.
  3. Click View, and then click Show Hidden Devices.
  4. Expand the Network Adapters tree.
  5. Right-click the dimmed network adapter, and then click Uninstall.

Here's the link to Microsoft's site for this error, Microsoft KB 269155

Tuesday, March 5, 2013

Access Denied when executing remote powershell

It's been a while since I've posted anything here, and I need to get back into the habit of adding to this blog as issues arise.

When trying to remotely run a PowerShell script you may find that you need local administrator access to the remote computer to successfully run the script. If not properly configured, you will receive an access denied message. A simple fix would be to add the user running the script to the local Administrators group, but we don't necessarily want to grant them this level of access.

If you haven't already done so, you must enable PowerShell remoting. This is done by running this command in PowerShell: Enable-PSRemoting on the remote computer. For more info on this command go to this technet link: Enable PSRemoting

Next you need to run this PowerShell command:
Set-PSSessionConfiguration -Name Microsoft.PowerShell -showSecurityDescriptorUI

Confirm that you want to perform this, it will then open a window allowing you to add users/groups with the appropriate permissions. You should now be able to remotely run your PowerShell scripts.

Note: This can impose security risks to your system, so please use this at your own discretion.

For additional information you may reference this page: PowerShell Blog

Wednesday, October 3, 2012

ExMon Unknown Start Trace Error (183)


When trying to run Exchange Monitor (ExMon) you may run into this error:




Here are the steps to fix this common problem.
  • From the CMD prompt, Query the running traces:
    • Logman query -ets
    • You should see one called "Exchange Event Trace"
  • To stop the Exmon trace, run this:
    • Logman stop “Exchange Event Trace” -ets
  • You should now be able to run ExMon