Showing posts with label Powershell. Show all posts
Showing posts with label Powershell. Show all posts

Monday, June 11, 2012

Rename and Move Files with Powershell

I have a software program that will import pictures into its database. Unfortunately it cannot accept files with the same name nor can it distinguish files from each other based off on what is in the file. It does however, index these files based on the file name.

If any of you have worked with a Sharp multi-function device, you might know that when  a person scans a document to a file, it is given a random name based off criteria you select. The criteria available is limited and I needed more precise file names so that the software could index properly.

Here is what i did. I set up different "Scan to network" locations based off the file name needed. For example, Credit Card receipts would have it's own address book button, and send it to a folder called CCR inside of a network share. I would then have a script ran every so often that would move it to the right folder based off its location so the Software could import it. Here is my script:



This will take all items in e:\import\ccr and then move them to e:\import_complete along with a completely different name. The $random variable is there so files will not have the same exact name. The software can then import them with the right indexes

Changing the primary SMTP address of Live at Edu Users

Have a name change to a student and need to change their primary email address? Unfortunately you will be unable to do that through the Web based management. You will have to use powershell to connect to your live at edu system run the following command

"set-mailbox user@campus.edu -windowsliveid newuser@campus.edu"

You can also do this to change campus.edu to a different campus. When this change is made the primary smtp address will be added as a secondary smtp address, so the recipient will still receive mail on that address. The WindowsLiveID will be changed, and they will need to log in using the new one. Need help connecting your powershell to Microsoft's? Use the following code:

Unified Messaging Extension Search

Trying to enable Unified Messaging to an Exchange recipient and it says the extension number is already assigned with another UM-enabled user? Here is a little script that will search your users for you in Exchange and let you know who has it.



The script must be run with the Microsoft.Exchange.Management.PowerShell.Admin snapin loaded in powershell. Simply run that script .\extsearch.ps1 and it will let you know which user has that extension. (it does take some time)

Scripting Live at Edu Account creation

The thing about automated account creation is that I have never thought it would save that much time. Creating a dozen or so accounts a day is not very time consuming. When i created a script that would automate it for me, I realized I would never want to go back. When my school wanted to move to Live @ Edu, I did not want to manually create them. I explored the possibility of using Identity LifeCycle Manager, but wound up just including the email account creation inside my AD account creation script.

Creating an account on Live@Edu requires three things.
1.) Password
2.) Windowsliveid (also the email)
3.) Name (also called the displayname)

So i define these variables and a few more in the main script, and call upon a second script to do the actual work. My second script:


As you can see, I define
$Display (which is lastname, firstname),
$liveid,
$password (which must be converted to securestring)
$firstname
$lastname

Connecting and disconnecting after each user will add quite a bit of time that your script needs to run, but it works great. Also keep in mind that you must put your administrative windows live id and password in plain text in the script, so it would be a good idea to keep it locked down.