Wednesday, December 15, 2010

10 PowerShell commands every Windows admin should know

Over the last few years, Microsoft has been trying to make PowerShell the management tool of choice. Almost all the newer Microsoft server products require PowerShell, and there are lots of management tasks that can’t be accomplished without delving into the command line. As a Windows administrator, you need to be familiar with the basics of using PowerShell. Here are 10 commands to get you started.

Note: This article is also available as a PDF download.

1: Get-Help


The first PowerShell cmdlet every administrator should learn is Get-Help. You can use this command to get help with any other command. For example, if you want to know how the Get-Process command works, you can type:
Get-Help -Name Get-Process

and Windows will display the full command syntax.

You can also use Get-Help with individual nouns and verbs. For example, to find out all the commands you can use with the Get verb, type:
Get-Help -Name Get-*

2: Set-ExecutionPolicy


Although you can create and execute PowerShell scripts, Microsoft has disabled scripting by default in an effort to prevent malicious code from executing in a PowerShell environment. You can use the Set-ExecutionPolicy command to control the level of security surrounding PowerShell scripts. Four levels of security are available to you:

  • Restricted — Restricted is the default execution policy and locks PowerShell down so that commands can be entered only interactively. PowerShell scripts are not allowed to run.

  • All Signed — If the execution policy is set to All Signed then scripts will be allowed to run, but only if they are signed by a trusted publisher.

  • Remote Signed — If the execution policy is set to Remote Signed, any PowerShell scripts that have been locally created will be allowed to run. Scripts created remotely are allowed to run only if they are signed by a trusted publisher.

  • Unrestricted — As the name implies, Unrestricted removes all restrictions from the execution policy.


You can set an execution policy by entering the Set-ExecutionPolicy command followed by the name of the policy. For example, if you wanted to allow scripts to run in an unrestricted manner you could type:
Set-ExecutionPolicy Unrestricted

3: Get-ExecutionPolicy


If you’re working on an unfamiliar server, you’ll need to know what execution policy is in use before you attempt to run a script. You can find out by using the Get-ExecutionPolicy command.

4: Get-Service


The Get-Service command provides a list of all of the services that are installed on the system. If you are interested in a specific service you can append the -Name switch and the name of the service (wildcards are permitted) When you do, Windows will show you the service’s state.

5: ConvertTo-HTML


PowerShell can provide a wealth of information about the system, but sometimes you need to do more than just view the information onscreen. Sometimes, it’s helpful to create a report you can send to someone. One way of accomplishing this is by using the ConvertTo-HTML command.

To use this command, simply pipe the output from another command into the ConvertTo-HTML command. You will have to use the -Property switch to control which output properties are included in the HTML file and you will have to provide a filename.

To see how this command might be used, think back to the previous section, where we typed Get-Service to create a list of every service that’s installed on the system. Now imagine that you want to create an HTML report that lists the name of each service along with its status (regardless of whether the service is running). To do so, you could use the following command:
Get-Service | ConvertTo-HTML -Property Name, Status > C:\services.htm

6: Export-CSV


Just as you can create an HTML report based on PowerShell data, you can also export data from PowerShell into a CSV file that you can open using Microsoft Excel. The syntax is similar to that of converting a command’s output to HTML. At a minimum, you must provide an output filename. For example, to export the list of system services to a CSV file, you could use the following command:
Get-Service | Export-CSV c:\service.csv

7: Select-Object


If you tried using the command above, you know that there were numerous properties included in the CSV file. It’s often helpful to narrow things down by including only the properties you are really interested in. This is where the Select-Object command comes into play. The Select-Object command allows you to specify specific properties for inclusion. For example, to create a CSV file containing the name of each system service and its status, you could use the following command:
Get-Service | Select-Object Name, Status | Export-CSV c:\service.csv

8: Get-EventLog


You can actually use PowerShell to parse your computer’s event logs. There are several parameters available, but you can try out the command by simply providing the -Log switch followed by the name of the log file. For example, to see the Application log, you could use the following command:
Get-EventLog -Log "Application"

Of course, you would rarely use this command in the real world. You’re more likely to use other commands to filter the output and dump it to a CSV or an HTML file.

9: Get-Process


Just as you can use the Get-Service command to display a list of all of the system services, you can use the Get-Process command to display a list of all of the processes that are currently running on the system.

10: Stop-Process


Sometimes, a process will freeze up. When this happens, you can use the Get-Process command to get the name or the process ID for the process that has stopped responding. You can then terminate the process by using the Stop-Process command. You can terminate a process based on its name or on its process ID. For example, you could terminate Notepad by using one of the following commands:
Stop-Process -Name notepad
Stop-Process -ID 2668

Keep in mind that the process ID may change from session to session.

Monday, November 29, 2010

Top 8 Traits Employers Look For

When looking for employment you should keep in mind the needs of potential employers. Of course you want the job – but what do employers want from you?

1. Loyalty – Loyal employees are the backbone of any organization. Look at your resume (or LinkedIn profile), does your work history seem like that of a loyal employee? If there are short term roles listed make it clear they were temporary jobs. Jobs not relevant to the role can be omitted. At interview do not gossip or share details of previous employers, colleagues or mutual acquaintances – indulging in tittle-tattle will make you appear disloyal.

2. Honesty – Employers need to be able to trust you. Never pad you resume, be honest about qualifications and experience. Nothing is more likely to make you appear dishonest than being caught in a half truth at interview.

3. Punctuality – Bosses need to know their workers will be at their posts on time every day as poor timekeeping can cost a company customers. Demonstrate good timekeeping by turning in your application form on time. If given an interview appointment make sure you arrive at least ten minutes in advance of you allotted time.

4. Determination – People who want to do well are much more likely to work with passion and gain results for their employers. When given the chance to question a potential employer at interview, don’t be afraid to ask about opportunities for advancement, as this will display determination and alert the interviewer to your desire to succeed.

5. Flexibility – The ever changing face of business means employers need workers who are willing to move with the times, adapting to the evolving demands of their role. Use your application form to demonstrate how you have been flexible in previous roles – if you took on extra responsibilities or undertook additional training make sure you let them know.

6. Smart Appearance – Whether you will be working in a formal or casual environment, it is important to take care with your appearance at interview. If you look scruffy employers may ignore your skills, assuming that someone who doesn’t take pride in themselves will be unlikely to take pride in their work.

7. Positive Outlook – Employers want go-getters on their team. Showing a positive outlook at interview is essential. If you have been made redundant from a previous role, don’t bemoan your fate to a potential boss, instead explain how excited you are to be exploring new opportunities.

8. Communications Skills – Communication skills are key. Ensure your application and resume are grammatically correct, ask a friend or family to look them over for you to help catch any typos or errors. At interview think before you speak, choose your words carefully and ensure they convey the message clearly. Don’t “um” and “ah” – it is better to take a few seconds to compose an answer than to say something stupid.

Demonstrating these eight key skills can help you land your dream role, and displaying these traits in your daily working life will make you stand out over other employees when the opportunity for advancement arises.

Saturday, November 20, 2010

Filesystem Utilization Korn Shell Script

Script will run in cron @ 6,8,10,12am and 2,4pm to check filesystems that are above 90% full.
95% is the percentage used across the board unless otherwise noted.
#!/bin/ksh
#######################################################################################################
# Created: Javier Blanco
# Creation Date: 11/06/2001
# Use: By all unix servers
# Description: Script will run in cron @ 6,8,10,12am and 2,4pm to check filesystems that are
# above 90% full.
# 95% is the percentage used across the board unless otherwise noted.
#
########################################################################################################
export AD1=unixadmins@xyz.com

export PG1=555555555@pager.net
export PG2=555555555@pager.net

df -k | grep -iv -e filesystem -e /var/nim/resources -e proc -e cd -e /var/mksysbs -e /usr | awk '{ print $7" "$4}' | while read LINE
do
FILESYSTEM=`echo $LINE | cut -d"%" -f1 | awk '{ print $1 }'`
PERCENTAGE=`echo $LINE | cut -d"%" -f1 | awk '{ print $2 }'`
if [ $PERCENTAGE -ge 95 ]; then

echo "The system `hostname` has caused a filesystem alert on `date`. The ${FILESYSTEM} is ${PERCENTAGE}% full. \\n You will recieve this message every 2 hours until either the problem is corrected or the root crontab entry is commented out.[dfchk.sh] \\n \\n " | mail -s "- $FILESYSTEM is at $PERCENTAGE " $AD1 $PG1 #$PG2
fi
done

High Availability and Hardware Availability

High availability is sometimes confused with simple hardware availability. Fault tolerant, redundant systems (such as RAID) and dynamic switching technologies (such as DLPAR) provide recovery of certain hardware failures, but do not provide the full scope of error detection and recovery required to keep a complex application highly available.

A modern, complex application requires access to all of these components:

  • Nodes (CPU, memory)

  • Network interfaces (including external devices in the network topology)

  • Disk or storage devices.


Recent surveys of the causes of downtime show that actual hardware failures account for only a small percentage of unplanned outages. Other contributing factors include:

  • Operator errors

  • Environmental problems

  • Application and operating system errors.


Reliable and recoverable hardware simply cannot protect against failures of all these different aspects of the configuration. Keeping these varied elements—and therefore the application— highly available requires:

  • Thorough and complete planning of the physical and logical procedures for access and operation of the resources on which the application depends. These procedures help to avoid failures in the first place.

  • A monitoring and recovery package that automates the detection and recovery from errors.

  • A well-controlled process for maintaining the hardware and software aspects of the cluster configuration while keeping the application available.


High availability vs. fault tolerance

The difference between fault tolerance and high availability, is this: A fault tolerant environment has no service interruption but a significantly higher cost, while a highly available environment has a minimal service interruption.

Fault tolerance relies on specialized hardware to detect a hardware fault and instantaneously switch to a redundant hardware component—whether the failed component is a processor, memory board, power supply, I/O subsystem, or storage subsystem. Although this cutover is apparently seamless and offers non-stop service, a high premium is paid in both hardware cost and performance because the redundant components do no processing. More importantly, the fault tolerant model does not address software failures, by far the most common reason for downtime.

High availability views availability not as a series of replicated physical components, but rather as a set of system-wide, shared resources that cooperate to guarantee essential services. High availability combines software with industry-standard hardware to minimize downtime by quickly restoring essential services when a system, component, or application fails. While not instantaneous, services are restored rapidly, often in less than a minute.

 Many sites are willing to absorb a small amount of downtime with high availability rather than pay the much higher cost of providing fault tolerance. Additionally, in most highly available configurations, the backup processors are available for use during normal operation.

High availability systems are an excellent solution for applications that must be restored quickly and can withstand a short interruption should a failure occur. Some industries have applications so time-critical that they cannot withstand even a few seconds of downtime. Many other industries, however, can withstand small periods of time when their database is unavailable.

Thursday, November 11, 2010

Caché System Failover Strategies

Caché fits into all common high-availability configurations supplied by operating system providers including Microsoft,IBM, HP, and EMC. Caché provides easy-to-use, often automatic, mechanisms that integrate easily with the operating system to provide high availability.There are four general approaches to system failover. In order of increasing availability they are:

• No Failover Strategy
• Failover Cluster
• Concurrent Cluster
• ECP Cluster

There are variations on these strategies; for example, many large enterprise clients have implemented ECP cluster and alsouse failover cluster for disaster recovery.It is important to differentiate between failover and disaster recovery. Failover is a methodology to resume system availability
in an acceptable period of time, while disaster recovery is a methodology to resume system availability when allfailover strategies have failed.

No Failover Strategy

With no failover strategy in place your Caché database integrity is still protected from production system failure. Structural database integrity is maintained by Caché write image journal (WIJ) technology; you cannot disable this. Logical integrity is maintained through global journaling and transaction processing. While global journaling can be disabled and transaction processing is optional, InterSystems highly recommends using them.

If a production system failure occurs, such as a hardware failure, the database and application are generally unaffected. Disk degradation, of course, is an exception. Disk redundancy and good backup procedures are vital to mitigate problems arising from disk failure.

Failover Cluster

A common and often inexpensive approach to recovery after failure is to maintain a standby system to assume the production workload in the event of a production system failure. A typical configuration has two identical computers with shared access to a disk subsystem.

After a failure, the standby system takes over the applications formerly running on the failed system. Microsoft Windows Clusters, HP MC/ServiceGuard, Tru64 UNIX® TruClusters, OpenVMS Clusters, and IBM HACMP provide a common approach for implementing failover cluster. In these technologies, the standby system senses a heartbeat from the production
system on a frequent and regular basis. If the heartbeat consistently stops for a period of time, the standby system automatically assumes the IP address and the disk formerly associated with the failed system. The standby can then run any applications (Caché, for example) that were on the failed system. In this scenario, when the standby system takes over the application, it executes a pre-configured start script to bring the databases online. Users can then reconnect to the databases that are now running on the standby server. Again, WIJ, global journaling, and transaction processing are used to maintain structural and data integrity.

To be continued

Wednesday, August 04, 2010

A New Era Started Today

Finally made the decision of buying a Digital SLR camera. After months of tedious research I narrowed my choice to the Canon EOS 7D. It's final! I ordered the 7D from Buyer Edge, an online retailer located in New Jersey. The setup is simple: Just the camera for now.