I've been seeing more and more instances of developers and administrators just disconnecting from RDP sessions on our servers instead of logging off. One I just find this irritating and two It leaves possible applications open on the servers and using resources. So to combat this issue I finally put the following scripts together.
The first looks for all RDP sessions that have been idle for more than 59 minutes on a filtered list of servers. It then compiles a list of all sessions with the same userID. It looks up the e-mail address of each userID in Active Directory and puts together a report of that list and e-mails it to the individual. Once all individual reports have been sent it sends a master list to a specified address (me). The function that gathers the RDP session info was written by Jaap Brasser http://www.jaapbrasser.com, I was half way through writing my own when I stumbled upon it but why would I want to reinvent the wheel?
The Second one I use to kill RDP sessions remotely quickly and easily. It uses Jaap's "Get-LoggedonUser" function as well but I've omitted it from the script box to save space.
Sunday, March 16, 2014
Saturday, March 15, 2014
My office is located in EST and we have a data center onsite but we also have another data center in CST. I don't know why but every so often we get some developers that don't understand that. So I have to sometimes find out why their code is an hour wrong or show them that they need to make their code time insensitive. I use this to do it.
I decided to give up on the code highlighter and throw some business the way of https://gist.github.com
I decided to give up on the code highlighter and throw some business the way of https://gist.github.com
Sorry for the sloppy script window here, still trying to figure out how to get it to show all neat and tidy on Blogger.
This Function I have found supper useful since at work to save drive letters many of our servers use mount points but we still haven't found a friendly way to check on the capacity and storage usage of them. This in combination of some other functions have become a staple of mine when checking system health and planning for additional storage needs.
- Function get-mountpoints {
- Param(
- [Parameter(Mandatory=$True,Position=1)]
- [Array]$PC
- )
- $volumes=@()
- $TotalGB = @{Name="Capacity(GB)";expression={[math]::round(($_.Capacity/ 1073741824),2)}}
- $FreeGB = @{Name="FreeSpace(GB)";expression={[math]::round(($_.FreeSpace / 1073741824),2)}}
- $FreePerc = @{Name="Free(%)";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Capacity / 1073741824)) * 100),0)}}
- $volumes = Get-WmiObject -computer $PC win32_volume | Where-object {$_.name -notlike '\\?\*'}
- $volumes | Select SystemName, Label, Name, $TotalGB, $FreeGB, $FreePerc | Sort-Object name | Write-Output
- }
First Post
I've just decided to create this blog where I hope to share some of the many scripts, functions and modules I've created. I also hope to share some of the lessons I've learned, usual the hard way to that others don't have to go through the hell I put myself through.
Subscribe to:
Posts (Atom)