This is simply for my personal reference since I keep searching for this. I usually use to check from AWS Systems Manager Session Manager. The answer is to run the command query user /server:$SERVER. The answer is from this StackOverflow question.
Tag: powershell
How to find the LDAP connection string of an AD User / Group with Powershell
This is simply for my personal reference as I am always confused on finding it as part of my projects, and I always forget what to search. So the answer is just a copy from Server Fault Type dsquery /? in a command prompt.
Bulk change retention period of AWS Cloudwatch Log Groups
By default cloudwatch log groups will have a retention period of “Never expire” set when created. If you have a lot of cloudwatch log groups and want to set retention period for all of them at one shot, use the following powershell code snippet. The script requires you to have the AWS CLI profile configured […]
Rename Windows and Linux EC2 instances based on tag
If you need to rename your EC2 instances based on the tags set, you can use the below code snippets. This can be particularly useful if you use a hardened AMI with a name already set in. To apply them, you can just use a cron job or a Task Scheduler job, or even cloudwatch […]
How to use sudo in powershell
Well this is not exactly same as sudo. However it is very annoying when I want to run something in powershell and it gives me access denied. And then I need to go to start menu, or task bar, right click, select run as administrator etc just to run one command. As someone who likes […]
How to export services and their users into csv
I need to export the services and their ‘run as’ users in a number of servers. This is how I did it. #Ebin Issac 6/3/2018 #This will read a list of servers from a text file, and extract the services which are not run by localsystem, and save into a csv file. Need to be […]
How to export group memberships of Active Directory users into CSV format..
So I started a new job recently, and I am working on a as-is migration. I needed to export the list of AD users and their group memberships into human readable format. So this is how I did it. $users = Get-ADUser -Filter * foreach ($user in $users) { $Groups = (Get-ADPrincipalGroupMembership -Identity $user.SamAccountName | […]
How to export the last login details of all users in a Windows server using Powershell
So one of our clients want to get a monthly report on the last login details of all users in the Windows servers in our environment. So we came up with this powershell script which is scheduled to run end of every month. This will extract the data, and upload them to an S3 bucket. […]
How to display a pop up message in a remote computer using powershell
In my daily work, there are times which I need to contact a user who is using a particular PC, but they don’t respond. Mostly, I need to contact them to inform about something, or get them to reboot, or install something etc. There are some cases which it is not possible, such as : […]