Mick's IT Blogs

My blog is here to help solve issues I have encountered and solved, publish scripts I have written, and educate others in understanding areas that are not well covered.

Mick's IT Blogs

Information Technology Zone

10 April 2014

How to remove shortcuts during an MSI installation

It is very easy to stop shortcuts from being installed during an MSI installation. The first thing you will need is ORCA or Super ORCA. These applications will allow you to open up and edit the contents of the MSI. Once you have the MSI opened up in either app, go to the shortcut table as shown in the pic below. Once there, right-click on each row and click drop-row. That is all that is to preventing shortcuts from being installed.

07 April 2014

MDT: Message containing password has been suppressed error

In my experience, this error was caused by me manually editing the unattend.xml file associated with an imported operating system. Specifically, I had manually entered the UnattendedJoin credentials within the unattend.xml file. Apparently when you manually enter the credentials in there, and they are in plain text, this error will occur when you override those credentials in the customsettings.ini file. To fix this, either re-import the operating system image or make sure the plain text credentials match in both the customsettings.ini and the unattend.xml files.

13 March 2014

PowerShell: Get list of installed printers

This function will get the list of printers installed for a user. It will also get the Default Printer. It outputs the list to Printers.txt, located at the location where the script is executed.

You can download the script here.

Function GetRelativePath {
    $Global:RelativePath=(split-path $SCRIPT:MyInvocation.MyCommand.Path -parent)+"\"

Function GetPrinterList {

    #Declare Local Memory
    Set-Variable -Name Count -Scope Local -Force
    Set-Variable -Name DefaultPrinter -Scope Local -Force
    Set-Variable -Name Printers -Scope Local -Force
    Set-Variable -Name Temp -Scope Local -Force
    If (Test-Path -Path $Global:RelativePath"Printers.txt") {
        Remove-Item -Path $Global:RelativePath"Printers.txt" -Force
    $DefaultPrinter = Get-WmiObject -Query " SELECT * FROM Win32_Printer WHERE Default=$true"
    $DefaultPrinter = $DefaultPrinter.ToString()
    $DefaultPrinter = $DefaultPrinter -replace [char]34,""
    $DefaultPrinter = $DefaultPrinter -replace "\\\\","\"
    $DefaultPrinter = $DefaultPrinter.split("=")
    $Temp = "Default Printer: "+$DefaultPrinter[$DefaultPrinter.Length-1]
    $Temp | Add-Content -Path $Global:RelativePath"Printers.txt"
    $Printers = Get-WmiObject -Query " SELECT * FROM Win32_Printer WHERE Default=$false"
    For ($Count=0; $Count -lt $Printers.Length; $Count++) {
        $Temp = $Printers[$Count]
        $Temp = $Temp.ToString()
        $Temp = $Temp -replace [char]34,""
        $Temp = $Temp -replace "\\\\","\"
        $Temp = $Temp.split("=")
        $Temp = "Printer: "+$Temp[1]
        $Temp | Add-Content -Path $Global:RelativePath"Printers.txt"
        Write-Host $Temp
    #Cleanup Local Memory
    Remove-Variable -Name Count -Scope Local -Force
    Remove-Variable -Name DefaultPrinter -Scope Local -Force
    Remove-Variable -Name Printers -Scope Local -Force
    Remove-Variable -Name Temp -Scope Local -Force

06 March 2014

PowerShell: Creating Active Setup Registry Key

Here is a script I just wrote that will create an active setup registry key. It prompts you for the title, description, command line execution string, and version. It generates a unique GUID to name the registry key. It then generates the registry key file and places it in the same directory as the script was executed from.

You can download the script from here.

     Author: Mick Pletcher
       Date: 06 March 2014
   Synopsis: This will generate the active setup registry key to
             deploy to machines so it iterates through every user that
             logs onto a machine.
Description: This will prompt for the title, brief description, version, and
             command line execution string. It then generates the .reg file
             and places it in the same directory as the script was executed from.

Function GetRelativePath{  

    #Declare Local Memory
    Set-Variable -Name RelativePath -Scope Local -Force
    $RelativePath = (split-path $SCRIPT:MyInvocation.MyCommand.Path -parent)+"\"
    Return $RelativePath
    #Cleanup Local Memory
    Remove-Variable -Name RelativePath -Scope Local -Force
Function GenerateGUID {

    #Declare Local Memory
    Set-Variable -Name GetGUID -Scope Local -Force
    $GetGUID = [guid]::NewGuid()
    $GetGUID = $GetGUID.ToString().ToUpper()
    return $GetGUID

    #Cleanup Local Memory
    Remove-Variable -Name GetGUID -Scope Local -Force

Function GetKeyInfo {

    #Declare Local Memory
    Set-Variable -Name ComponentID -Scope Local -Force
    Set-Variable -Name Description -Scope Local -Force
    Set-Variable -Name StubPath -Scope Local -Force
    Set-Variable -Name Version -Scope Local -Force
    $ComponentID = Read-Host "Enter the title"
    $Description = Read-Host "Enter brief description"
    $Version = Read-Host "Enter the version number"
    $StubPath = Read-Host "Enter the command line execution string"
    $StubPath = $StubPath -replace '\\','\\'
    Return $ComponentID, $Description, $Version, $StubPath
    #Cleanup Local Memory
    Remove-Variable -Name ComponentID -Scope Local -Force
    Remove-Variable -Name Description -Scope Local -Force
    Remove-Variable -Name StubPath -Scope Local -Force
    Remove-Variable -Name Version -Scope Local -Force

Function GenerateRegKey ($RelativePath, $GUID, $KeyInfo) {

    #Declare Local Memory
    Set-Variable -Name File -Scope Local -Force
    Set-Variable -Name Text -Scope Local -Force
    $File = $RelativePath+"ActiveSetup.reg"
    If (Test-Path $File) {
        Remove-Item -Path $File -Force
    New-Item -Name ActiveSetup.reg -Path $RelativePath -ItemType file -Force
    $Text = "Windows Registry Editor Version 5.00"
    Add-Content -Path $File -Value $Text -Force
    $Text = [char]13
    Add-Content -Path $File -Value $Text -Force
    $Text = "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{"+$GUID+"}]"
    Add-Content -Path $File -Value $Text -Force
    $Text = "@="+[char]34+$KeyInfo[1]+[char]34
    Add-Content -Path $File -Value $Text -Force
    $Text = [char]34+"ComponentID"+[char]34+"="+[char]34+$KeyInfo[0]+[char]34
    Add-Content -Path $File -Value $Text -Force
    $Text = [char]34+"StubPath"+[char]34+"="+[char]34+$KeyInfo[3]+[char]34
    Add-Content -Path $File -Value $Text -Force
    $Text = [char]34+"Version"+[char]34+"="+[char]34+$KeyInfo[2]+[char]34
    Add-Content -Path $File -Value $Text -Force

    #Cleanup Local Memory
    Remove-Variable -Name File -Scope Local -Force
    Remove-Variable -Name Text -Scope Local -Force


#Declare Global Memory
Set-Variable -Name GUID -Scope Local -Force
Set-Variable -Name KeyInfo -Scope Local -Force
Set-Variable -Name RelativePath -Scope Local -Force

$RelativePath = GetRelativePath
$GUID = GenerateGUID
$KeyInfo = GetKeyInfo
GenerateRegKey $RelativePath $GUID $KeyInfo

#Cleanup Global Memory
Remove-Variable -Name GUID -Scope Local -Force
Remove-Variable -Name KeyInfo -Scope Local -Force

26 January 2014

How to clean up your Facebook profile of old posts, messages, pictures, and videos

All of us have posts that we want to clean up from the past. They may be posts that are now embarrassing, posts with exes that we want gone off of our profile, or maybe you are interviewing for a job that you know asks for your credentials and you want to make sure your profile looks good. Facebook does not allow the average user to be able to easily see posts from a long time ago. If you are a geek and know how to use Facebook's FQL, you can query all previous posts for specific keywords. There are a couple of options:

  1. You can go into the general account setting and click on Download a copy of your Facebook data. This will download all of your facebook data divided up into separate files for each section of your profile, including all of your pictures and videos. Once you have the download, you can then open up the wall.htm file in Excel. It contains all of your wall posts from the beginning of your profile. In order to use this, you can search the spreadsheet for keywords. The results will have the exact date/time it was posted. You can then go to your Facebook profile and find that exact post by clicking on the year first, then the month, and finally scrolling through all posts in that month to find the specific post. You can then click on the drop-down and select Delete.
  2. There is a Facebook app called Search My Posts. This app will allow you to enter keywords and will parse through your profile and find all posts with that keyword. For posts on your profile, this will allow you to click on the Link to Post to take you directly to the post. You can then click on the drop-down and select Delete. This app will also list posts you did on other people's profiles, but does not have a link to the post. You will have to note the date/time, go to the user's profile, and then click on the year/month to parse through all posts for that month until you find your post. At that point, you can delete your post. The same goes for posts you made in groups.
As for recommendations, this solution pertains to both of the above posts. You cannot remove a recommendation from Facebook. You must go to the web page that you clicked on the Facebook recommendation. The way to do this is to click on the link to the Facebook post, if you are using option 2, or go to the date it was posted for option 1, and then click on the link in the Facebook post to take you to the page that was recommended. It is there that you can now click on the Facebook recommend again to remove the recommendation. Once you remove the recommendation, the post disappears off of Facebook.

As far as Facebook messages goes, Facebook has archived the messages in the past, meaning they were not deleted. When you go into your messages box, there is an archive box that you can click on. It is there that you will find all of the messages from the past that were archived. They can now be deleted. You first click on the message. Next, you click on actions and click Delete Conversation. That will permanently delete the message from your Facebook profile. 

For your pictures and videos, I suggest using the first option, or manually parsing through them on your profile. 

Keeping your Facebook profile safe and out of trouble in civil court, criminal court, work, and home life is wise. I would leave out alcohol, guns, sex, violence, and topics of controversy off of Facebook. These topics can cause you to lose your job, lose your family, be sued, or incriminate you in a criminal court system. If you have any of these topics on Facebook, I suggest cleaning them off. I am not a criminal/civil/psychology expert, but common sense will tell you these things, especially in today's digital world. Information is magnified and misconstrued by many because the reader inject their own emotion into the text, not yours, thereby possibly leading to ramifications. 

Labels: , , , , , ,

How to search all of your Youtube comments

If you have been trying to find a way to search through all of your Youtube comments you have ever posted, there is a way. Youtube does not seem to have a feature that allows for you to see all of your comments, but you can use their parent company, Google, to find them. Go to google.com and enter the line below. Change the <Youtube Account Name> to your Youtube account name and then hit <enter>. All of your Youtube comments will pop up.

site:youtube.com/all_comments "<Youtube Account Name>"

19 January 2014

Robocopy: How to exclude a directory on the destination while using the mirror switch

I ran into a situation where we had to mirror our local DFS to all of the remote DFS locations. The problem was that there was one directory in each of the remote shares that was unique to that location and had to remain untouched. The first thing I thought of was to have powershell parse through the base directory trees and perform a recursive robocopy on each base. There were 177 with thousands of subdirectories under each one. That was just too much. I finally figured out to make sure there was also a directory in the source DFS named the same as the one in the destination that is to remain unchanged. Once that directory was in the source, I was able to exclude the directory from the source and it left the directory in the destination untouched.