Friday, October 28, 2011

CMD Print DIR to text file

dir > print.txt

The ">" symbol is telling to put the output of the command to whatever is next. In this case "print.txt". This is useful for writing any output to a file in a script or whatever.

Example: dir > %USERPROFILE%\Desktop\print.txt

This example will print the directory listing to print.txt on your desktop.

Other flags:

dir /b file names only

dir /s include all sub folders & files

Original source: http://www.computerhope.com/issues/ch000772.htm

Actually I really like that site, and spent some time taking their quiz. Entertaining.

Sunday, October 23, 2011

CMD combine CSV files into one

I had the need to combine several CSV (excel) files into one file. The set was long enough that even opening them and copy/pasting would take over an hour. This little trick will do it in a few seconds. (in windows)

1. Put all of your files in the same folder. They all need to be CSV format and should be the only CSV files in the folder. You may want to remove headers from your spreadsheets if you don't want them later.
2. Open a command prompt. Windows+R > cmd This should be the normal command prompt because it doesn't work in powershell.
3. Navigate to the folder with your .csv files
4. type "copy *.csv newfilename.csv"
5. A new file named "newfilename.csv" will show up in the same folder. If you wanted to copy it somewhere else you could run copy *.csv path\newfilename.csv.

Example: copy *.csv %USERPROFILE%\Desktop\newfile.csv




















This will copy all the CSV files from the folder you are in to a file on your desktop named newfile.csv. 


I'm sure this can also be done with any type of text-only file.

If you need to do it on another type of spreadsheet file, you'll want to save copies as CSV first.

Note: if you run this more than once, you will want to delete or move the newly created file before running again. Otherwise the new file will be copied in with the rest and you'll have a lot of duplicates.


I think this is where I found the original answer.
http://www.pcreview.co.uk/forums/do-you-combine-multiple-csv-files-into-one-file-t1739041.html

Tuesday, September 6, 2011

Save communicator chat history in outlook

For some reason, our installation of communicator was set not to save any messages by default, but it did save my call history. 

Since I don't have any juicy communications at work, I don't have any problem saving everything in communicator. I save those chats for gchat. By the way, administrators of communicator can view your conversations in communicator, so I would be careful when using it. They also control if these settings are available, so you might not be able to change much anyways.

When this option is selected, your chat messages and history will be saved to a folder in Outlook named "Conversation". (Image) Enabling this is very easy. It's done in Communicator, NOT in Outlook.

1. In Communicator go to file, tools, options...

2. Check the box that says "Save my instant message conversations in the Outlook Conversation History folder"

After restarting you will have a folder in Outlook that will save your chats from now on.


Here are my sources, which I'm sure you will find before this site, so I don't even know why I wrote this.

http://office.microsoft.com/en-us/communicator-help/frequently-asked-questions-HA010289995.aspx

http://weblogs.asp.net/coltk/archive/2010/04/29/enable-office-communicator-chat-history-in-outlook.aspx


Thursday, March 24, 2011

Only one processor showing XP

This fix is if Windows XP is only showing one processor on a multi processor/core machine.

1. Boot to safe mode with networking 

2. Delete (or rename) the following if they exist from C:\WINDOWS\System32\
hal.dll
ntoskrnl.exe
ntkrnlpa.exe
(Check for these. They usually do not exist but delete them if they do)
halmacpi.dll
ntkrnlmp.exe
ntkrpamp.exe

3. Copy the following into C:\WINDOWS\System32\ from the files described in the bottom note.
hal.dll
ntkrnlpa.exe
ntoskrnl.exe

4. Reboot and it should fix itself the rest of the way.  

NOTE: The new files in step 3 were taken from the originals which can be found on other machines in C:\WINDOWS\ServicePackFiles\i386:
halmacpi.dll renamed to –>HAL.DLL
ntkrnlmp.exe renamed to –>ntoskrnl.exe
ntkrpamp.exe renamed to –>ntkrnlpa.exe

Thursday, March 3, 2011

Outlook 2010 - Change default from-address gmail

It took me a while to figure out how to change the default from address in Outlook when using gmail or a google apps account. I've done it in Office 2010. This will make your alias the default email address when sending any emails. It won't say "on behalf of" or anything like that.

1. Set up gmail account in outlook if you haven't done so already
http://mail.google.com/support/bin/answer.py?hl=en&answer=77689

2. In file tab, open Options





3. Select Advanced Tab


4. Send/Recieve...




5. Edit...



6. Select your account and click Account Properties...


7. IMAP E-mail tab


8. Change E-mail Address: (not User Name)


Now when sending emails from the original account, the email address will actually be the new one even when the original account is selected.

Note: You can't use google apps sync with this solution; you have to use use calendar sync if you want use the calendar also.

If you just want to change the from address once, you can do this:

1. Create a new email
2. In options, select the from field
3. in the From tab, select "other email address" and put whatever address you want

Wednesday, January 26, 2011

Admin Group Policy fails to apply

Problem: 

  • Group Policy doesn't apply, but gpresult doesn't show any problem.
  • Some Policies are working on the same computer
  • The same policy is working on other computers
  • The windows log has an error with something like this:
    • The client-side extension could not remove computer policy settings for ' ' because it failed with error code '0x8007000d The data is invalid.' See trace file for more details.

Solution:

  • Delete all files in this path: C:\ProgramData\Microsoft\Group Policy\History
  • In Windows XP: D:\Documents and Settings\All Users\Application Data\Microsoft\Group Policy\History
  • In a command window run "gpupdate /force"



I ran into a problem where our administrator group policy was not applying for some reason, while other policies were applying. I could not find any information in gpresult or in any group policy settings or information. The policy is the same that is on all the other machines in the domain, and was working, except for one or two machines. 


I've spent several hours searching for a solution to this problem, and I we've re-imaged computers because of the problem, the actual solution will only take you 5 minutes. Other policies might not be applying also such as the password reset, even though they show that they are applying in gpresult. 


The problem is a corrupt file in this location: C:\ProgramData\Microsoft\Group Policy\History. The solution is to delete everything in that folder and let Group Policy re-create it with gpupdate /force.


To give credit, here's where I found the solution. It might have a better answer anyways.
http://tools4pros.blogspot.com/2009/05/group-policy-error-0x8007000d-data-is.html

Wednesday, January 19, 2011

Export Domain Users to CSV with PowerShell

If you would like to create a list of all domain users in excel with a powershell script you are in luck. Quest software has created some pretty awesome tools to manage Microsoft Active Directory. Here's how to do it:

1. You'll need to install the Quest ActiveRoles management shell v. 1.4 or later, located here: http://www.quest.com/powershell/activeroles-server.aspx

2. Create a PowerShell file with the following script. Basically, just copy this text into a text file and rename the extension to .ps1.



#This script requires Quest ActiveRoles management shell v.1.4 or later and Powershell to be installed. http://www.quest.com/powershell/activeroles-server.aspx
#The script may be run on any machine that is bound to the domain and actively connected. You do not have to be a domain administrator.
#Two files will be created. One CSV with results and one TXT log file.

$strTimestamp =  [string](Get-Date -format "yyyy-MM-dd_hh-mm")
start-transcript DomainScriptLog-$strTimestamp.txt #starting log file to verify that the script did not have any errors.

Get-Date -format s

# $strFilePath = ($Home + "\My Documents\") 
#This is the path of the logged in user. Use this if you want to save to My Documents (add below into csv-export and out-file commands, otherwise it will save where the script is located.

$strFileName = ("DomainUsers_" + $strTimestamp + ".csv")
Write "Writing File to $strFileName. This may take some time..."

#set sizelimit to 0 for full list
#you can set the various attributes that you would like as columns here
Get-QADUser -Sizelimit '0' -ShowProgress -ProgressThreshold 0 | select-object Name, SAMAccountName, givenName, sn, title, manager, employeeID, employeeNumber, employeeType, defaultGroup, postalAddress, City, postalCode, PasswordNeverExpires, AccountIsDisabled, Description | export-csv ($strFileName) -notype

#this will put a timestamp in the file if it finished correctly
"Execution Completed successfully starting $strTimestamp ending: " + [string](Get-Date -format "yyyy-MM-dd_hh-mm") | Out-File ($strFileName) -append
Write "Execution Complete"
Get-Date -format s
stop-transcript



3. Open the Quest ActiveRoles Management Shell for Active Directory program that you installed in step 1 and find the ps1 file that you created. If you run it in normal a normal PowerShell it won't work. Your computer should be logged in to a domain account and have an active connection. The process may take a while, but this script includes a progress bar as well as telling you which account it's working on.


PowerShell script with progress bar




4. You might get an error saying:

"File ....ps1 cannot be loaded. The file ....ps1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signing" for more details.."

You can either figure out how to digitally sign the script by following these long instructions:
http://www.hanselman.com/blog/SigningPowerShellScripts.aspx

Or you can just turn off the check because you know what it's doing:
Set-ExecutionPolicy Unrestricted
http://technet.microsoft.com/en-us/library/dd347628.aspx



If you want to query specific groups such as admins, there's a similar tutorial here:
http://www.yanzzee.com/2011/01/use-powershell-to-create-domain-admin.html

Wednesday, January 12, 2011

Export Domain Admins to CSV with Powershell

It would be nice to be able to run a PowerShell script to query certain domain groups in Microsoft Active Directory, and write them to .CSV files for easy review in excel. Here's one way to do it:

1. You'll need to install the Quest ActiveRoles management shell v. 1.4 or later, located here: http://www.quest.com/powershell/activeroles-server.aspx

2. Create a text file with .ps1 extension, and the following text. You can review the comments in the script to see what each part does, or just google the commands you don't know. Quest has some documentation last time I checked.



#the AD groups that will be queried. These are groups that are considered domain admins
$aGroups = @("Administrators", "Domain Admins", "Server Operators", "Enterprise Admins", "Account Operators", "Backup Operators", "Group Policy Creator Owners", "Schema Admins",  "Domain Controllers")

#where the results are saved. you may want to change this
$strOutputPath = "C:\Users\username\Desktop\"

#creates a time-stamp for the file name
$strTimestamp = [string](Get-Date).Year + "-" + [string](Get-Date).Month + "-" + [string](Get-Date).Day + "_" +  [string](Get-Date).Hour + "-" + [string](Get-Date).Minute

#the query happens for the groups provided above, and will record the details listed here and export it to a csv file for each with the timestamp
foreach ($group in $aGroups){
Get-QADGroupMember $group -Indirect -Type 'user'| select-object Name, sAMAccountName, title, manager, employeeID, employeeNumber, employeeType, associatedDomain, ObjectClass, defaultGroup, postalAddress, City, postalCode, PasswordNeverExpires, AccountIsDisabled, Description  | export-csv ($strOutputPath + "_" + $strTimestamp + "_" + $group + ".csv") -notype
}



3. Run the powershell script on a domain machine that is currently on the network. You will have to open the Quest ActiveRoles Management Shell that you installed in step one. You should get a CSV file for each group specified. You shouldn't have to be a domain admin to run the script successfully, but your user and computer should be on the domain.

4. You might get an error saying:
"File ....ps1 cannot be loaded. The file ....ps1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signing" for more details.."

You can either figure out how to digitally sign the script by following these long instructions:
http://www.hanselman.com/blog/SigningPowerShellScripts.aspx

Or you can just turn off the check because you know what it's doing:
Set-ExecutionPolicy Unrestricted
http://technet.microsoft.com/en-us/library/dd347628.aspx