Sean's profileEnergized About Technolo...PhotosBlogLists Tools Help

Blog


    November 28

    Powershell – How to Digitally Sign Scripts for FREE

    powershell_logo

    One of the biggest features that sets Powershell aside from all other scripting Languages is the ability to ensure the code CAN be trusted.  By signing that script with a Certificate you can ensure that scripts meant to run on a particular machine are only from that machine or more particularly from within your department, division or company.

    What stops most of us from doing this are usually cost (Certificates usually cost money) or just a lack of knowledge.

    Well guess what?  We’re going to put that knowledge in your hands, and it DOESN’T have to cost anything.   You don’t even need a Domain or Certificate infrastructure just to USE this.

    Because the tool is free, the instructions are free.   You can buy a certificate of course but if you’re a small business, you may not want to incur that cost to run scripts on a single server.

    What do you need to do this?

    The freely downloadable SDK for your version of Windows (I don’t think you need to download the entire kit) and Powershell

    That’s it.   Oh and a few minutes time.

    The instructions are sitting right inside Powershell too if you want to read up on them.   I found the easiest way was to just use the Powershell ISE Help System and search for “digital” or “signature” and you’ll see a reference to “about_signing”.   There’s your instructions.   But here’s the quick version.

    Run these two commands, and when prompted for a password, key one in. 

    makecert -n "CN=PowerShell Local Certificate Root" -a sha1 ` -eku 1.3.6.1.5.5.7.3.3 -r -sv root.pvk root.cer ` -ss Root -sr localMachine

    makecert -pe -n "CN=PowerShell User" -ss MY -a sha1 ` -eku 1.3.6.1.5.5.7.3.3 -iv root.pvk -ic root.cer

    To verify it was created correctly

    get-childitem cert:\CurrentUser\my –codesigning

    Once you know the Cert is there and running well You can Digitally Sign your Powershell Scripts

    $cert = @(Get-ChildItem cert:\CurrentUser\My -codesigning)[0]

    Set-AuthenticodeSignature NAMEOFSCRIPT.PS1 $cert

    Which will take the script called NAMEOFSCRIPT.PS1 and digitally sign it.  That’s it! 

    Now you can lock down execution of Powershell scripts on that environment

    SET-EXECUTIONPOLICY –ExecutionPolicy AllSigned

    You now have a Server running the scripts securely.  And in such a way that that unless the scripts are signed with a certificate they can’t run automatically.

    And I wasn’t kidding either.  It WAS easy!

     

    Sean
    The Energized Tech

    November 27

    Powershell – How Do I Learn? Where Do I Start?

    powershell_logo

    I had a good friend the other day ask the Community. 

    “I want to learn Powershell?  What books should I read?  Where do I start?”

    And the problem is that you will get 100 answers, all of them correct.

    The problem is that Powershell, as it’s name implies is incredibly POWERFUL.  And to a new person taking a look at the online community and the features it has, it can be overwhelming at the amount of available scripts written by people.  

    And you may have the same reaction I had.  “Oh I could NEVER do ANYTHING like those scripts, I should just shut up so I don’t look stupid…”

    And that’s the flaw.

    The material online for Powershell all started somewhere.  Everybody knew NOTHING about it at one point or another.   And your best resource is those magic six words.

    “I don’t know, I’ll go ask…”

    What actually seems to work for me is something as simple as (and that’s how I started learning) “I have a need to repeat something en masse or for consistency.”

    If it can be done in a Login Script, it gets done there.  GPO there.

    If' it has anything at all on ANY level to do with WMI, Active Directory, working with the Registry, manipulating files, date, logs, Powershell.

    So what helped me learn Powershell was that magic thing that drives all ITPros and Devs.  “I NEED a solution.  I need one I can easily repeat and replicate with consistency.”

    What I found worked best for me was to realize I was “repeating something” and could this be scripted in any way?  The reason for this was with an automated solution, the results were more consistent and faster.   So to learn Powershell, find a need you have.   Learn how to do that NEED in Powershell.   The solution is probably online.   And once have it full filled, you may want to understand how that solution works, and why.

    The Syntax of the language is simple.   A “VERB-NOUN” structure.  Running a “GET-COMMAND” will show you all the commands, “ALIAS” will show you all the Aliases.

    That doesn’t teach you Powershell.  What teaches you Powershell is just using it, for something simple.   Get comfortable with just ONE feature.  Even if it’s just using “GET-CHILDITEM” to navigate the file System.   Get really comfortable with using that one feature with a “GET-MEMBER” to learn how to pull out properties (information) and Methods (functions which modify the output)

    In short, Play with Powershell on a small level and get comfortable with it.  Because ALL of the fancy stuff, all the nifty stuff all works the same way.

    And don’t be afraid to ask, nobody in the Powershell community thinks there are silly questions.

    Because one day, we were all asking them ourselves.

     

    Sean
    The Energized Tech 

    November 26

    Using the SEND-MAILMESSAGE command in Powershell V2

    powershell_logo

    This might seem like such a simple command to be ecstatic about, that is unless you’ve ever tried to script emailing log files.

    Oh it’s doable.  There’s vbScripts that do it.    They just, well… they’re ‘wordy’

    They’re not horribly complex to be honest, but it seemed to me at the time there had to be an easier way.  Since the vbScripts themselves weren’t exactly in ‘English’

    But now There is

    Powershell V2’s new “SEND-MAILMESSAGE

    The Syntax of the command is a little eye popping as it any piece of software at the command level.


    Send-MailMessage [-To] <string[]> [-Subject] <string> -From <string> [[-Body] <string>] [[-SmtpServer] <string>] [-Attachments <string[]>] [-Bcc <string[]>] -BodyAsHtml] [-Cc <string[]>] [-Credential <PSCredential>] [-DeliveryNotificationOption {None | OnSuccess | OnFailure | Delay | Never}] [-Encoding <Encoding>] [-Priority {Normal | Low | High}] [-UseSsl] [<CommonParameters>]

     

    But really, it’s very easy.  

     

    SEND-MAILMESSAGE –to johnqsmith@contoso.com –subject ‘BackupLogs’ –from backup@contoso.com SmtpServer 10.0.0.10

     

    There you’ve sent a simple mail message of nothing from one line.  And read it.  You don’t have to be a developer to understand what that means!

    SEND an eMAILMESSAGE to johnqsmith@contoso.com from backup@contoso.com with a SUBJECT of ‘BackupLogs’ to the SMTP Server which was 10.0.0.10

    And if you need to tuck in an attachment like those backup logs, just plug in the –attachment parameter with the location of the file in question.

     

    SEND-MAILMESSAGE –to johnqsmith@contoso.com –subject ‘BackupLogs’ –from backup@contoso.com SmtpServer 10.0.0.10 –attachment ‘C:\BackupLog\Logfile.log’

     

    That’s the beauty of this, a command that just makes dead simple sense.  So there you have it, Powershell the nicest “MAIL”man you’ve ever met

    Sean
    The Energized Tech

    Powershell – The Easiest way to mine for files

    powershell_logo

    It was brought to me the other day.  

    “We have this file buried in an old server, only thing we know about it is the day it was created.  But we need it now…”

    *** NOW ***

    Ever had one of those?

    Well this was not an issue.  We did know the type of file it was, we just had to dig through 125,641 copies in hundreds of subfolders, Sure, easy…

     

    But it was actually, because I had Powershell.

     

    Now I could have sat down and done some really cool script but you don’t have to get fancy with Powershell to get the job done.  And remember you can ALWAYS refine it later.

    So I needed to just put this down as I was thinking it

     

    “I want a list of ALL the files in the Archive.”

    GET-CHILDITEM D:\BIGHONKINARCHIVE –recurse

     

    “Ooops… wait a minute… I want a listing of all WORD documents in that structure.”

    GET-CHILDITEM D:\BIGHONKINARCHIVE –include *.DOC recurse

     

    “Better…but actually just the ones made in 2003…”

    GET-CHILDITEM D:\BIGHONKINARCHIVE –include *.DOC –recurse | where { $_.LastWriteTime.Year –eq ‘2003’ }

     

    “Ok this is nice smaller list, but really I want the stuff done in November 2003”

    GET-CHILDITEM D:\BIGHONKINARCHIVE –recurse | where { ($_.LastWriteTime.Year –eq ‘2003’) –and ($_.LastWriteTime.Month –eq ‘11’)}

     

    “Ooooo, now could I just have the ones done on the 26th?”

    GET-CHILDITEM D:\BIGHONKINARCHIVE –recurse | where { ($_.LastWriteTime.Year –eq ‘2003’) –and ($_.LastWriteTime.Month –eq ‘11’) –and ($_.LastWriteTime.Day –eq ‘26’) }

     

    Now the first part I should state is this is NOT the most efficient way to do it.  But what it DOES show is you can easily use Powershell as an amazing search tool to mine through your folders.   And more importantly, you can write it out as you’re thinking about it the WAY you’re thinking about it.

    You could even (with a little pipe) have Powershell examine the contents of those files and determine which ones might have the content you needed.

     

    Oh somedays I wonder, what was life like BEFORE Powershell?

    Oh yes, right.  I forgot.

    It was horrid.

     

    Thanks Powershell!

    Sean
    The Energized Tech

    November 20

    Techdays Calgary – A View from a Volunteer and comment from the Community

    Day One of Techdays_CA in Calgary

    IMGA0002

    Up at 5:00am.  5:00am MOUNTAIN STANDARD TIME.

    The day began actually at 4:48am with me up BEFORE the alarm clock.   The excitement was unbearable.

    I was up running about the room, getting ready to go out the door.  Up before the alarm clock could go off and out the door.

    IMGA0011

    And in the early hours before 8:00am where it was still dark, final preparations were still ongoing. Volunteers scrambling about to make sure everything was setup, demos loaded up, machines powered.   A last few Internet connections to double check and batteries to plug in

    And the day began.  

    IMGA0017 IMGA0016 

    The crowds began to move in, past the registration desk into the main dining Area.   One thing I will say about Calgary, they REALLY know how to get things done!  I looked at the layout of the room and my jaw dropped.   Such an amazing dining area including the Windows 7 area prepped with various renditions of Multi Touch PC’s from Dell and HP.   The new Ford Flex.

    IMGA0021

    And truly the community showed it’s support and interest.   Each and every session at Techdays_CA Calgary was packed not only with information but people intensely interested in that session.    It also reflected the intense desire of people wanting to know just how that technology COULD be (but not necessarily SHOULD be) leveraged.

    And it showed one other small thing.

    Common interests.  

    IMGA0030

    I’m from Toronto (Much farther east) and you could hear people talking about similar problems and issues.   People were looking for answers, or in some cases pieces to the puzzle.    There were some things that might be unique to their particular area but for the most part, people were very curious about Windows 7, especially the newer UAC or Multitouch.   Many people genuinely didn’t know about the Media Center Extender and were very impressed when all the content was accessible from a single location.   People were very impressed that a computer in the house could interface in that manner.

    I for one, would VERY much like to see that technology extended to OEM’s.   I think if the market was to have a pile of systems that could interact in that manner with people, the face of computing would change.   I personally can’t wait to see “Project Natal” released for the Xbox360.   I expect it to have issues (like first generation Voice Recognition did) being a VERY new technology.   But sit and think for a moment.

    A computer where YOU go to it, and *IT* immediately begins to work with YOU on YOUR terms rather the classic “type type, click click”.   MultiTouch and “Project Natal” (If that were to extend to the PC world) would COMPLETELY change the face of computing as we know it.  Security, Login, Interaction.  

    Many didn’t realize about how many free tools Microsoft offers to the public to make their jobs easier, there were some *I* didn’t know about! And although we all understand the value of getting it for free, there is also greater value in having an Enterprise level solution you can easily manage.

    For a full TWO DAYS this continued.   Interest did not fall back, it continued.  Especially in both sessions at Day end that I was involved in.   In both Toronto and Calgary I personally noticed that the room was full each time with people tired from a long day but so intensely interesting in learning something, they would stick it out to the end.

    For my part I found many of us had a common nemesis, Mr. “Murphy S. Law, Attorney in Troublemaking”.   And we fight the unknown and unexpected daily.   All of us.

    IMGA0028 IMGA0029

    And of course Techdays_CA brought forth Community.   I ended meeting a few new people and maybe (just maybe) inspiring a few new people to “Try something different” even if that something is Microsoft technology OR more importantly, stepping out and getting involved with the IT Community.

    Getting involved not because Microsoft says you should, getting involved because it’s an extension of yourself and some of us are afraid to take chances and look foolish.

    Well I’ll tell you one thing.

    Take the chances, look foolish, make mistakes.   Because if you try and fail or try and succeed, you always learn something.  Take that to heart from one guy who spent his entire life afraid to try.  It is WORTH it on levels beyond describing to take that “dip in the pool”

    And at Techdays_CA one thing I have learned is there truly *IS* always something more to learn.

    Even as people

    Sean
    The Energized Tech

    November 13

    Powershell – REMOTING oh WHAT a wonderful thing!

    powershell_logo

    I’m going to start with something you should be aware of when working with Powershell.  You CAN access a lot of information remotely without Powershell Remoting. 

    You can without question.

    It’s just a lot slower and not as Powerful.   I can do a GET-EVENT from a remote computer and get it’s event log.   But it’s just SLOOOOOOOOOOWWWW!!!

    With Powershell Remoting your life is a breeze!

    And it’s REALLY easy to work with too!

    First off both machines have to be running Powershell V2.

    Machines receiving the “Remote Instructions” need to have Remoting enabled

    And you need  a few minutes to play.  Yes it’s THAT easy.

    There’s two types of remoting I’ve started to play with.  One is more of a DIRECT interaction remote Shell, and the other actually runs remote commands and let’s you received the data locally.

    The second is the coolest!

    So stage one.  Enabling Remoting on the “Remote System”

    In an Elevated Powershell Prompt (Run as Administrator) execute the following command

    Enable-PSRemoting

    You will get prompted to allow it to run afterwards since Ps Remoting is enabling features and adjusting Firewall settings to allow it to run

    image

    Select “A” for Yes to All (I promise it won’t hurt you) and allow to run through.  You’ll need to be connected to the network and running in a Domain Profile or Private network profile to work.   It will take a few moments and now the machine is ready to accept remote Powershell connections.

    But how to use them?

    Ahh well THAT is the easiest bit.  Here’s the “Direct Console” method which effectively has you running commands locally but executing and processing remotely.

    Just run a

    NEW-PSSESSION –computername REMOTECOMPUTERNAME

    ENTER-PSSESSION –computername REMOTECOMPUTERNAME

    That’s it!  You’re now connected to that computer running commands as if you were logged into running a normal Powershell prompt.

    To exit just type

    EXIT-PSSESSION –computername REMOTECOMPUTERNAME

    Now that wasn’t so difficult was it?

    But HERE is coolness.   It’s the ONE feature I’ve been dying for.   Invoke command remotely but have the results piped to you locally!

    And what do you know?  You use INVOKE-COMMAND

    So if type

    INVOKE-COMMAND –scriptblock { get-childitem } –computername REMOTECOMPUTERNAME

    That will actually run a ‘get-childitem’ in the default context (file system) on the computer called “REMOTECOMPUTERNAME”.  And the really cool bit is what results from that command I can save and work with (including Piping) LOCALLY.

    Can you see the potential here?  Get entire event logs from a DC, filter them for what you want and look at the results locally on your Excel spreadsheet!

    So this example

    INVOKE-COMMAND –scriptblock { GET-EVENTLOG –LOGNAME ‘Application’ | where { $_.EntryType –eq ‘Error’ } } –computername REMOTECOMPUTERNAME

    Will pull down the Application Event log from that remote computer.  I can put that data DIRECTLY into a EXPORT-CSV via a pipe, or make a more specific script and have it filter for certain types of data.

    But the import detail here is one thing.  It is SO much faster and SO much more powerful.  Because of Powershell?  It wouldn’t take much to Query Active Directory for a list of Servers and query ALL the Event logs and pull down a nice fancy report from the result!

     

    Powershell – I love You

    Sean
    The Energized Tech

    November 11

    Microsoft Desktop Optimization Pack – Put WinRE into OVERDRIVE - WOW!

    My eyes are open and they have SEEN the LIGHT!

    If you are wondering and humming and hawing about having an Open License with Microsoft and are unsure about Software Assurance?  I just found the nail to close the sale for you!

    There is additional cost, and the fact that a new version “Might” get released isn’t enough for some people.  I can completely understand that.

    But MDOP! the Microsoft Desktop Optimization Pack for Software Assurance is MANNA from the gods! And is PART of Software Assurance!

    Ok first off you get MED-V which allows you to have Virtualized legacy environments running seamlessly on the Back end so anything that is old and NEEDED can STILL run on Current technology solidly and SEAMLESSLY.  App-V as well.  These two environments alone independent of Windows 7 can bring Compatibility to levels you’ve never seen.

    But to boot you get ADVANCED Group Policy Management that lets you roll out and roll back different Group Policies, Asset Inventory and Systems Center Desktop Error Monitoring.  More power to monitor and extend your networks abilities in one package.

    Any ONE of these would open up my eyes like giant pancakes.

    But then I met “D.A.R.T.” – the Desktop Application Recovery Toolkit.  

    DART takes the Windows Recovery Environment (WINRE) and extends its wings and MAKES IT FLY!  “D.A.R.T.” builds an ISO file with more power than you could ever want.  But that Boot.WIM file it builds is ALL WinRe based.

    So guess what?  With a little clicking here and there (or just a handy MDT / WDS setup in the backend?) You can boot into the GREATEST single tool to help systems repair and recover in any Environment, Enterprise or Small Business.

    DART contains a Malware scanner, A strong Registry Editor, the Ability to reset Local Admin Passwords, File Undeletion, MBR repairs for the Partition, HOTFIX Removals and even a decent version of Explorer!

    WinRE is a gorgeous piece of technology.  And It’s free with Windows 7 and Server 2008R2.  But adding DART to WinRE launches it like a Rocket!

    If you’re considering Software Assurance?  Consider the fact the ability to Undelete files alone as a backup Data Recovery plan ALONE could more than pay for the value of Software Assurance, or an even MORE Guaranteed factor in your environment to ensuring Maximum recoverable uptime!

    So my workstation is now testing out DART.  The only drawback with my Workstation being Windows 7 is it’s so darn stable?

    I don’t get to see things break.

    MDOP.  Seriously look into it for your organization.

    Sean
    the Energized Tech

    Powershell – Getting a List of ACTIVE computers from Active Directory

    powershell_logo

    I had a question in our User Group during Powershell Script Club.   Would he be able to use Powershell to show a list of all computers in Active Directory?

    Well I took a shot at it tonight.

    With Quest Active Roles installed I ran a

    GET-QADCOMPUTER | EXPORT-CSV C:\Computers.csv

    and examined the Headers from the CSV file in Excel to see what data was available.  I spotted about four date columns but it appears there was some duplication but the useful ones seem to be “CreationDate” and “ModificationDate”

    CreationDate seems simply enough to be the Date the object got Created in Active Directory

    ModificationDate seems to be the last time the Object was accessed in A/D by the computer for any reason.  It also seems to contain a date field that is update somewhat quasi regularly by a live system.

    So running the process is typical date compare stuff.  Store the current date and Compare against the date

     

    $COMPAREDATE=GET-DATE

    GET-QADCOMPUTER | WHERE { $_.ModificationDate.CompareTo( $COMPAREDATE.AddDays(-90) ) –eq $TRUE }

     

    Should give us a nice simple list of computers that are ACTIVE within the network in the last 90 days.

    Now mind you this is not a precise science.  I wouldn’t just go ACTIVELY purging objects with this, but at least it can help you see a list of Computer Objects you can probably purge in the A/D

     

    And of course if your Pipe that into an EXPORT-CSV you can get a nice list in Excel to see and work with.  

     

    $COMPAREDATE=GET-DATE

    GET-QADCOMPUTER | WHERE { $_.ModificationDate.CompareTo( $COMPAREDATE.AddDays(-90) ) –eq $TRUE } | EXPORT-CSV C:\IDLECOMPUTERS.CSV

     

    Keep in mind as well, if you have Virtual Machines that don’t normally get powered up and SIT for 90 days, they would also fall into this list.  Thus why I said use it as a reference list. DON’T and I repeat DON’T just pipe this into a Remove-Object without a –whatif unless you’re in a Test Domain.

    Or unless you’re looking to get fired really quick.

     

    Powershell

    It just makes life EASIER!

     

    Sean
    The Energized Tech

    November 11th - Remembrance Day - Lest We Forget

     
    Remembrance Day

    So long ago
    A time long forgotten
    When madness
    engulfed our world
     
    Shouts of terror
    Screams to Silence
    So much anger
    And cries of despair
     
    Confusion and Chaos
    And attempts to lay down order
    Crimes of the Guilty
    The Punishing of the Innocent
     
    A time when the few
    Stood up to the many
    A world divided
    A world united
     
    Days long ago
    When our Father's Fathers
    And Mother's Mothers
    Fought each other
    And Side by Side
     
    So that we
    Their many children
    Their unknown offspring
    Could have today
     
    To live
    And breathe
    With the Right
    To say 'NO' to the darkness
     
    And most importantly
    To Remember
    Their mistakes
    Their Sacrifices
     
    That we might stand today
    And live to
    learn from them
    And Grow
     
    So today
    This Nov 11th
    On that 11th hour
    Pause for a moment
     
    And Remember
    What They did
    And Gave up
    For you today
     
    Sean P. Kearney
    November 10

    Group Policy Preference Client Side Extensions - Disabling Office Addins via Registry

    Ran into a small stumbling block today on the Network. 
     
    I had a user request to have an Add-In Disabled on the workstation.    No problem easily done.
     
    Go to list of Add-ins and just "Clear the Box".
     
    But I thought for a moment, I like being Laz..... I mean "Centrally Efficient" and controlling as much as possible from Group Policy.  Oddly enough (And maybe I'm missing it) I couldn't find a GPO to control Addins at all.   Either to deploy, or more importantly, to disable.
     
    But if you're running Server 2008 with a newer Domain?  You've get a GREAT Feature called Group Policy Preference Client Side Extensions you can leverage.  And it will work on Windows XP, Vista, Server 2003 and Windows 7 as long as you have the Group Policy Preference Client Side Extensions Hotfix installed on the workstation.
     
    For Windows XP          - Download Here
    For Windows XP x64    - Download Here
    For Windows Vista       - Download Here
    For Windows Vista x64 - Download Here
    For Server 2003           - Download Here
     
    For Windows 7            - Built right in!
     
    So if you have a Server 2008 Environment with the newer Group Policy there is an addition option now called "Preferences".  These DON'T Negate the regular Group Policy options.   Think of them at what they are, Extensions.   Do GPO's the normal way but there's a whole new way of tweaking very specific features like drive Mappings etc.
     
    Or today, applying Registry settings!
     
    So in my case I had to Disable the Office Live Addin.  Nothing wrong with it, but we just don't need it in our environment.   So we'd like it disabled.  
     
    So under HKEY_LOCAL_MACHINE\Software\Microsoft\Office there are a series of keys for Word / Excel / Outlook etc. ( If you're on a 64bit workstation the actual location is HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\ )
     
    Under each entry you will see "Add ins" with a Subkey for each Add in, like this
     
     
    The Value to note here for each key is called "Load Behaviour".  If it has a value of '3' it will run the add-in automatically, if it has a value of '2' it is "Disabled" although still present in the file system.  I like disabling rather than uninstalling, far easier to "Flip the switch on" if needed.
     
    And you can probably even use a script to do this do.  But with Group Policy Preference Client Side Extensions, I can push that Registry change to my workstations centrally.
     
    I just go to the Computer Configuration in Server 2008 GPO, Pop into the Preferences for there and you'll see an Entry that says "Registry"
     
     
    Just Right Click on Registry, Choose "NEW, the Registry Item" and fill out the forms as appropriate.
     
     
    You can even browse to the key but for now we'll type the details in directly.
     
    Hive is "HKEY_LOCAL_MACHINE"
    Path is "Software\Microsoft\Office\Word\Addins\OLConnectorAddin.Connect" (That's the Key we're modifying)
    Value Name is "LoadBehaviour" (since that's the value we're changing)
    Value Type is "REG_DWORD" (since that is the original value type, you can tell by viewing with REGEDIT)
    Value Data is "2" (Normally for Addins it's '3' which is enabled, '2' is disabled, I found this out by changing the settings and looking at values after)
     
    This will disable the Office Live Com Addin in Word.   If you need to do this for Excel?  Just change the Path to "Software\Microsoft\Office\Excel\Addins\OLConnectorAddin.Connect"
     
    Also note, if you're working on a 64bit machine, and since Office is a 32bit app, it's path will be "SOFTWARE\Wow6432Node\Microsoft\Office\Word\Addins\OLConnectorAddin.Connect"
     
    But you CAN control all these addins from Group Policy thanks to Group Policy Preference Client Side Extensions.   It takes a tiny bit of thought, but it's worth the effort since you can now manage all of this for anything from 5 to 50,0000 workstations EASILY!
     
    I love Technology
     
    Sean
    The Energized Tech
     
    November 09

    Powershell - Easy Reporting of Files/Folders Accessed

     
    We all know that I have a Deep love affair with Powershell. 
     
    So much so my wife comes into the basement with a faint Blue haze over my face each night, wondering just WHAT the heck I'm doing huddled over my PC.
     
    Today I got to play with Powershell again.   Sometimes it's the simplest things it solves that makes it so wonderful.
     
    How would YOU like to pull up a report on a file system of Folders which were modifed?  Easily?  and Free?
     
    That is something you can do with Powershell without even trying.
     
    In your Filesystem, the Modified Date field is easily accessible.   And easy to compare with any date.  Like say the current date?
     
    So just simply assign the Date to a Variable with a GET-DATE
     
    $CURRENTDATE=Get-Date
    And of course pick a target to Scan
     
    $TARGETDIRECTORY='C:\'
     
    And pick how far to compare with, say anything modified in the last 60 days?
     
    $COMPAREDATE=$CURRENDATE.Adddays(-60)
     
    And then gather all those goodies into a variable to pick and choose with.
     
    $FILELIST=GET-Childitem $TARGETDIRECTORY -recurse
     
    And then casually dig through the list
     
    Foreach ($file in $filelist)
    {
         $Written=$FILE.LastWriteTime
         if ($written -gt $comparedate) { $FILE }
    }
    Now granted this is not the most beautiful code ever written but it's easy to look at and modify.
     
    We can take ALL of this and make it into a nice little script too prompting for the Number of days to look back as well as the folder to examine.
     
    --------------------- LISTACCESSED.PS1 ------------------------------
     
    $CURRENTDATE=Get-Date
     
    # Ask for Folder to Scan
    $TARGETDIRECTORY=READ-HOST 'Which Directory to Scan?'
     
    # Prompt for Number of days for output
    $DAYSBACK=READ-HOST 'How Many Days in the Past?'
     
    $COMPAREDATE=$CURRENDATE.Adddays(-($DAYSBACK))
     
    $FILELIST=GET-Childitem $TARGETDIRECTORY -recurse
     
    Foreach ($FILE in $FILELIST)
    {
         $Written=$FILE.LastWriteTime
         if ($WRITTEN -gt $COMPAREDATE) { $FILE }
    }
    --------------------- LISTACCESSED.PS1 ------------------------------
     
    Now this is all nice a simple, dumping a list of information to your screen but run this SAME Script in Powershell and Pipe to an EXPORT-CSV and you'll have information you can use in Excel or your choice of Spreadsheet and mine through your file system just to see what has been getting used (or not) for archival purposes.
     
    LISTACCESSED.PS1 | EXPORT-CSV C:\MYREPORT.CSV
     
    Don't you just love it when life get's easy?
     
    Sean
    The Energized Tech
    November 02

    Night of the Living Undead Processes – Happy Halloween :)

    The silence blows through the air like the sound of a thousand dead thermal fax machines.  The air is brim with calm and quiet and horrid writing.

    It is a night, a night ripe for terror!  It is Devils night, the night before Halloween.

    A late night data entry clerk is sitting down, keying in mounds upon mounds of useless data into an oversized database.  A long night it seems.  Exceedingly long.

    Our poor hapless victim ...er data entry clerk....has stepped up for a moment to go refill his can of "unnamed corporate caffeinated beverage so I can't be sued." He turns and inadvertently bumps the remainder of his drink onto the desk.

    "EEEEP!" he shrieks in a high pitched girlish scream as he quickly tries to mop up the mess with his worn out sweaty shirt.

    But it is too late.  The sweat and soda and whatever else was on the desk have oozed through their way to the computer below.   Crawling and melding it's oozy smelly sugary way into the heart of the system. The smell of BO and Soda burns in the air along with an, as of yet, un-named third and completely un-identifiable smell.

    The smell is not relevant however.  What is, is the sound. Indistinguishable it sits in the background working up the spine of the living. Roaming throughout the room and omnipresent.  Like the smell of a thousand burning Kaypros, it hangs in the air.

    "Wow, never seen THAT happen from a soda spill!" Our hapless vict.... Hopeless idiot states.  He runs out (Convenient timing eh?) to grab a towel to sop up the rest of the mess.  Quickly drying up the mess he heads out, hoping the mess will be blamed on somebody else.

    Returning to the room, stupid the Data Entry Clerk views a completely indescribable sight, a sight which only responds with one sound as he is enveloped into nothingness.

    *GLOMP!*

    During the night Charlie the unwary and completely and utterly helpless janitor; who just so happens to be wandering the hallways; hears the noise.  It is coming from the vents.   Suspecting it to be a rat or small child roaming aimlessly within the ducting system, he grabs a broomstick to shoo it off.  Opening the access port, he hears the noise.  Low and rumbling. Deep and foreboding.   Calling out to potential Darwin Award winners everywhere.

    And hungry, very hungry.  "More Brainz ... Brainzzzzzzz... more brainzzzz" it echoes in a slow dull rumbling sound.  

    "Odd.   The heating vent isn't usually this chatty." mutters Charlie shaking his head POKEing the vent and jabbing with uncertainty, and stupidity.

    It was at that point the broomstick suddenly disappeared into a puff of illogic.   Charlie looked inside.  Quickly disappearing himself into nowhere.  Swallowed up by bad spaghetti programming echoed from Basic 4.0 on Commodore Pets from ancient past.

    *GLOMP!*

    Unwitting readers now scratching their head at this point looked for clarification.   But clarification was not for them to be had.  Clarification requires documentation and clearly defined parameters.   On this night, the parameters were NULL and VOID and the variables random.

    Only one thing would come to light.  (or dark).  The Living Undead Processes had been spawned.   sHell itself had opened up.   Nothing was safe anymore. (or any when).  Resources would shriek out in terror tonight, Users would cry in agony.   And writers of good horror stories would sob at this poorly written idea.

    They roamed the halls.  They roamed paths, crawling through directories and subfolders.  They roamed random thoughts of the author seeking one thing.  Brains.   Big thick juicy brains.  With Ketchup.  And perhaps a side order of Flies.  

    the Living Undead Processes, ripe with the taste of fresh Janitor ala Broomstick were looking for more brainz.  But being a late night, nobody else was really there.  And so they hid in a back hallway and suspended themselves until morning.  A scheduled task to awaken them at the appropriate hour.  And spawn the Daemons.

    Time passed...

    And passed further....

    And yet further on...

    Until... yes UNTIL.

    Morning.  October 31st.

    11:00am, deep into the work day, the living Undead Processes spawned free and began their Task of CONSUMING resources and Brainz.   Slowly, outwards from the vents, they seeped out.   The smell of brainz were fresh indeed.  Deep inside the IT Department four score of people deep into Product Development and one lone IT Pro.

    But before diving deep into the meal, the Undead processes went for a little snack.

    "Apples!" cried the leader as it spotted the Marketing Department.  Yes rows upon rows of delicious, electronic glowing Apples.  But no, not Macintoshes.  Classic Apples.  Running on Floppy disks no less. 

    A roar of delight came from the Undead Processes as they dove in the circuit boards and began gnawing on the minimal storage of the floppies,  Gnawing and chewing, they almost didn't notice a small band of hapless marketing staff walking

    in from their trip to a "completely unnamed coffee shop" that MIGHT end in the name BUCKS.  ALMOST.

    "Yes well Jenny, I personally believe that using a bit of mauve to top of the schema on the third la...."

    The sentence never finished.

    The Undead Processes launched from the ancient computers, routing through the wireless, completely indescribable to their victims.  Surprising them with both untested speed and surprising blocky graphics.

    "BRAINZ! BRAINZ!"

    The Helpless marketing staff never knew what hit them. Shrieks and screams of terror as in moments, they too began hosting the unstoppable entity known as the Undead Processes. 

    *GLOMP!* *GLOMP!* *GLOMP!* *GLOMP!*

    The moaning and staggering began.

    "BrAiNzzzzzz!  bRAinnZZzzzz!!!!" slurred the Marketing staff and the Undead Processes now linked as one.   Old IEEE488 cables were fashioned to create a strange and horrifying pseudo network.   The Undead Processes were now, no longer trapped.   They began to spawn further creating multiples of themselves.

    the Roaming began slowly through the halls.  

    Into the hallways.  Working their way towards the secured domain know as IT.  "BrAAAIINNNZZ! BrAiiNnnnzzz!"

    Along the way, they spotted terminals and users.   They consumed the minds of the users and attempted to access the network, seeking more resources along the way.   But with the weak credentials, they could gain nothing.  They needed IT.

    They craved the unlimited and powerful resources held within the brains of IT.  

    "Brainzzzzz!!" The growing army of Living Undead Processes, moaned out.  Now tied together with bits of old Arcnet, Token Ring and pieces of Zip drives.    Slurring and dragging horribly misspelled phrases and badly created slices of code. Spitting randomly created batch files.  Coughing Hollerith punch cards everywhere.

    Down to the deepest levels,  Scarfing down Managers, Copy staff and people in the Call Center.   The Living Undead Processes grew.  A large and empty maw of nothingness taking over the entire office.  Devouring Fax numbers and Calendar entries as well. Brainz and Resources their diet.   With the occasional MP3 collection as a dessert.

    *GLOMP!* *GLOMP!* *GLOMP!* *GLOMP!*

    The Office began the slowly disappear.

    Soon, they arrived at the entrance to the IT Department.

    *Beep* (RED LIGHT)

    *Beep* (RED LIGHT)

    The access cards they had acquired were all useless.   Nobody had the rights to the Domain of IT except for IT.

    But the Living Undead Processes were not stupid.  Having consumed enough people in Accounting, they knew where 36% of the IT budget went.  They knocked on the door.

    "PIZZA DELIVERY! Free booze! Dancing girls!"

    The door opened a crack, just enough to slip some code, or a hapless Developer out.  

    And too late for our friend, *GLOMP*, he was consumed by the Living Undead Processes.   They licked their input channels in delight at this newly acquired resource.   It was good but still lacking something.   The taste was not quite right.

    They tried the new Swipe Card. 

    *Beep* (RED LIGHT)

    *Beep* (RED LIGHT)

    "PAAARRRRRRGGGGHHH!!!" came the sound of a former Nurse.  "It's a COOP Student!"

    It was true.  IT sent a pawn for it's bidding.  A traditional tactic.   Good to keep Managers at bay.  Or random armies on Halloween of Living Undead Processes.

    The Living Undead Processes formed a Pseudo Discussion Group and began looping through ideas.   PUSHing ideas into a huge STACK.

    "We musssssst enter the IT Domain!  We neeeedddds their Braaaiiiinzzzz!!" Muttered the Undead Processes as one  with Unification.   "Trickssss them we willll..."

    "Taunts them with baublesssss we mussssst."

    "SCHWAAAAG! Gives 'dem SCHWAAAAG!"

    They knocked again.

    "Free TechNet Direct!  Free MSDN! Sign up now!"

    Squeeeeeaaaak! (the door to the Holy chambers creaked open, two tiny blinking pairs of eager eyes looked out.)

    *GLOMP! GLOMP!*

    Soon two more hapless victims and their hardware were consumed, but still...

    "PAIGH!  MORE CO-OP students!  Their tassssssste is lacking assss issssss their ressssourcesssssss….."

    The former head of Accounting growled out....

    "They weres inflatingsssss their budgetsssss I thinkssssss.... Unpaid staff!  These are smart onesssss.... Their Brainzz we must havveee..."

    The nothingness echoed.  "The IT Department we must have...."

    Meanwhile, the disappearance of three co-op students did not go un noticed.   Although it was quite common for  Co-Op students to disappear for hours at a time, they did not usually exit with a sound of crunching bones and *GLOMP* noises.

    The lone IT Pro examined the security camera.  

    Quickly he messaged the rest of the paid Development Team (all three of them) through his Communicator R2 application.

    ITDEPT: Problem in Office.  Management and staff appear more "dead" that usual this morning.
    CODELORDZ: Anything odd on the system last night?
    ITDEPT: Checking logs.   Basement Data Entry system, spawned an overload.   Suspect leaking memory and one less Data Entry Clerk.
    CODELORDZ: Anything sign of anything unusual?
    ITDEPT: Checkings cams.  Oh great.  Caffeinated Beverage all over Terminal. Missing Janitor too.  Ugh!
    CODELORDZ: Big problem.  That means only one thing.  Undead Processes.  Lots of them.  And by the sounds, Hungry
    ITDEPT: Undead Processes?  So that means no TASKKILL on this one.  
    CODELORDZ: And unfortunately copying them to /DEV/NULL on that Linux router on the back corner won't kill them either.
    ITDEPT: How do you kill an UNDEAD Process?
    CODELORDZ: Normally you'd just try to shoot off the SOURCE Undead Process that spawned them all into an endless loop. That doesn't kill them, but it renders them useless.
    ITDEPT: Why can't we do that?
    CODELORDZ: Because the source code was eaten with that last Coop Student. WE errrr.... left it on Floppy disk.  :)
    ITDEPT: :( Store all code on the TFS in future! So you can't kill an undead Process but you can keep it busy?
    CODELORDZ: Yes, they just consume and consume resources, but they're not very Smart Processes.  They're like CP/M 2.2 applications.
    ITDEPT: Ahhh, hang on..... I think I have an answer, it will involve a recursion routine... and perhaps another Co-Op student

    Handing off a new laptop to Ernie, the newest and most eager of the Co-op students.  His task was simple.

    “Bring this outside, and we’ll make you a Systems Administrator…”

    Our hapless little Vict…. Voluntold eye’s lit up

    Out in the hallway, the Undead Processes had found a small cache of mice and were gnawing on the cables for nourishment.  "Braiinnzzz!  We want Braaiiiiinnnzzz!" They groaned hungrily eyeing the entrance to IT

    ...Squeeeeeeeaaaaaaakkkkk!...

    The lone Co-op wandered outside with a DuoCore laptop, 16 gb of ram with mirrored 1 Terabyte hard drives.   And an unlocked desktop!

    “Woohooo! I’m a Systems Administrator now! YEAH! Woohoo! Wooo…..” cried the silly fool.

    The scent of this large irresistible resource was too much for the Undead Processes.

    "ARARARARRRAAAARRRRGGGHHHH!!" The processes leaped out and consumed the student *GLOMP* and dived in the laptop.

    " I HAVEEEEEE HISSSS CREDENTIALLLLLLSSSSS!!!" The Source UnDead Process cried out!  It Haaaaaasssssss DOMAIN ADMIN RIGHTTSSSSS!!!!!"

    Logging in, they drooled

    USERID       Voluntold-CoOp
    Password    Ub3rk001R@d
    DOMAIN     IT

    Diving in, they looked, "RESOURCES!!!! UNLIMITED POWER AND RESOURCESSSS!!! YESSSSSS!!!!" The Undead Processes roared out.  They consumed the recursion routine and began growing, growing phenomenally.

    One by one they exited their victims, diving into their prey.   An Unprotected Domain.   Soon the floor was littered with the shells of many staff.  Now Brainless without Process or Purpose. 

    The Domain Roared with CPU usage, Page files overloading with storage wasted.  They began to roam the LAN to seek out and find...

    "NOTHINGS!!! THERE IS NOTHINGS!!!! TRICKS USSSS!"

    IT smiled.   The domain, being virtual, smelled real and powerful, but was as useless as a Webcam on a Dos 3.3 computer.

    "NOOOOOO!!!!! " the screams of the Undead Processes roared in agony as the child partition of the Hyper-V Virtualization domain went to sleep.  Quickly the screaming of their WAV files vanished.

    IT smiled as it quickly, quietly and simply scrambled the VHD files by recursively zipping them with Random passwords, destroying the Undead Processes.

    ITDEPT: Make sure we put in a call for some extra Co-Ops in the morning.
    CODELORDZ: :) Appears we finally found a good use for them, what about all those empty shells in the hall?  No Brainz, Dead to the World?
    ITDEPT: Never fear.  Just sit them back down at their desks.  Nobody will be able to tell the difference. :)