Posts

PowerShell: Update User Permissions for a Shared Mailbox or Calendar using Add-MailboxFolderPermission

 I use this simple script to update permissions for a Shared Calendar for a group of Users.  This can be used for updating permissions to other Shared Mailbox Folders also. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #Connect to Exchange Online Connect-ExchangeOnline -UserPrincipalName alex.g @COMPANY .com #Create a list of User email addressses by seraching specific OUs and adding them to a users variable. $users = get-aduser -filter * -SearchBase "OU=MEC_Operations,OU=MEC,OU=COMPANY Users,DC=COMPANY,DC=local" -Properties mail | Select-Object mail $users += get-aduser -filter * -SearchBase "OU=COL_Operations,OU=COL,OU=COMPANY Users,DC=COMPANY,DC=local" -Properties mail | Select-Object mail $users += get-aduser -filter * -SearchBase "OU=HAR_Operations,OU=HAR,OU=COMPANY Users,DC=COMPANY,DC=local" -Properties mail | Select-Object mail $users += get-aduser -filter * -SearchBase "OU=RIC_Operations,OU=RIC,OU=

An Offboarding Script for On-Prem Active Directory

A while back I wrote an Offboarding Script that I still maintain.  It has saved me a ton of time throughout the years.   This code does several things, So let's go through the steps. Step 1. Import the Active Directory (AD) module into Powershell. Step 2. Prompts the user to enter the username of the user being offboarded. Step 3. Gets information about that user and sets those objects to variables. Step 4. Disables the account Step 5. Generates a random password and resets the user's password to the new randomly generated password. Step 6. Sets one of the extension attributes to today's date for use in a later account deletion script. Step 7. Gets the OU the user resides in and adds that information to the log file generated at the end of this script. Step 8. Gets the permissions, security groups, and distribution lists the user was a member of and adds them to the log file. Step 9. Clears all user permissions. Step 10. Moves the account to the Terminated OU. Step 11. Imp

A script to check a log file. If conditions are met the script will then delete, and copy in a file into the folder.

Image
 I wrote a quick script to automate a process I found myself doing every few months.   We have software that has a maximum number of licenses available. Unfortunately, when a user logs out, the software does not release that license.  To solve this issue we simply delete a .log and .dat file, and then paste a old copy of the .dat file back into that location.  Sounds kind of complicated, but it might make a little more sense looking at the script.  Lets take a look: The software will output a license count to a logfile that looks something like this. So in order to get the license count, we need to pull that log file into PowerShell, split it on the empty space, and then count the numbers remaining.  This was a little complicated for me to figure out but this is what I came up with. $split = Import-Csv C : \Users\alexg\Desktop\Scripts\license.log -Delimiter " " -Header Name,Amount $Count = $split | Measure-Object 'Amount' -Sum | Select-Object -expandP

Bulk AD User creation Powershell Script

Image
 As a follow up, I want to post of one of my most recent scripts.  This script is used to do bulk AD user creation.   My company has been growing rapidly and it takes up a lot of my time when creating and setting up new employee accounts and mailboxes.  I recently spent some time writing a script to automate this process.  This script takes a CSV file that has been filled out by HR with the new employee's name and other information.  It imports that information into Active Directory and creates a user profile.   Our hiring managers often include in the service ticket the name of an employee who would have the same rights/permissions/and memberships as the new employee.  So to simplify things, I put in my CSV file a column that is the "User to Copy".  This tells the script to copy that user's profile/OU/memberof details and apply them to the new user.   Once created, the script then starts a remote session into our On-prem Exchange Server, sets up a mailbox and links i

One of my first PowerShell scripts.

 In my current role I have been afforded the opportunity to learn and expand my knowledge of Powershell.  I've been reading books and watching videos to get the basics down.  The most helpful thing that I have found is to actually have a project to work on and to spend lots of time googling.   My first Powershell script came about due to a ticket that had sat in the que for quite some time.  The ticket requested to have location and organizational (tile/department) information displayed in Exchange.  I first had to contact HR to get a list of all employees with their department, and job title.  Lucky for me, they pulled this information from our HR database in the form of a CSV which saved me time editing and inputting the information into an excel spreadsheet and converting it to a CSV. With this information in hand I could get to work.  I needed a script that imported the CSV, and updated the provided information.  This is what I came up with: 1 2 3 4 5 6 7 8 9 10 11 12

It's been a while

 It's been a while since I've posted on this page, but I wanted post and update.  I an currently working as a Service Desk Analyst for a Transportation company.  Its a small group of guys but they have a TON of experience.  I started at the end of November 2020 and have learned a lot in the past 6 months.   For starters, I have gained experience with Active Directory.  I learned how to add, disable, edit users.  I've also learned how OU's affect everything from Network Folder access to permissions.  Part of my responsibilities include new user creation and account deactivation.  I have written a script in Powershell that creates a new user from information provided in a CSV file, it will copy the permissions of a user in a similar role.  Additionally it will create and link an exchange mailbox for the new user. On the less technical side of things, I am responsible for hardware maintenance and replacement/upgrades.  We have been transitioning away from HDD to SSD in our

Laptop Battery Replacement

Image
     I recently replaced the battery in one of my laptops. For the past few months I have been living with a battery that has drained quickly, even after charging over night.        The process was simple and did not require any special tools. Best of all it only took a few minutes to complete.        The Laptop in question was a Toshiba Satellite L55t-A5186. I picked this laptop up second hand from a individual who mainly used it for work. It was well cared for, but it is older.      Anyways, to replace this battery I had to remove a number of screws (12) from the bottom of the laptop. One of the screws held the CD-ROM drive in place. The CD-ROM drive must be fully removed in order to be able to pull the bottom off of the laptop. The CD-ROM drive is located on the right side of the laptop (if looking at the bottom of the Laptop), and just slides out after removing one of the 12 screws on the bottom.     Another part that needs to be removed is the RAM compartment cover. I'm not su