Posts Tagged 'PowerShell'

Delete Files Remotely Using PowerShell Script

Keep Reading ...

To run this with out reading a list just remove the commands at the the bottom and replace the “$_” with computer name or replace the $file variable with local path
123456789101112131415#MAIN
function delete-remotefile {
    PROCESS {
                $file = "\\$_\c$\File_to_be_deleted.txt"
              [...]

Enumerate last user login times from Active Directory via powershell

Keep Reading ...

123456789101112131415161718192021222324# ==============================================================================================
#
# NAME: UserLastLogin.ps1
#
# AUTHOR: John Sorensen
#
# COMMENT: This script uses the DirectorySearcher object to search for all users in Active directory.
#      It then walks through the user accounts and determines the last logon date.
#      
#
# ==============================================================================================

$searcher = New-Object DirectoryServices.DirectorySearcher([adsi]"")
$searcher.filter = "(objectclass=user)"
$users = $searcher.findall()

Foreach($user [...]

Query Scheduled Tasks using Powershell

Keep Reading ...

To use this powershell script place the script, the config file, and a list as a cvs file with the servers to be queried all in the same directory.
Save below as QueryScheduledTasks.ps1:
12345678910111213141516171819202122232425262728293031$Description="Generate CSV of scheduled tasks from a list of servers"

#——————————————————————————
# Settings / Variables
#——————————————————————————
If (Test-Path "QueryScheduledTasks.config") {
    $cfg=[xml](get-content "QueryScheduledTasks.config")
} Else {
    Write-Host "!! [...]

Exchange 2007- Who’s logged in to what mailbox… when?

Keep Reading ...

One thing I missed about Exchange 2003 was being able to easily go into the mmc and view the user and logon/logoff for every mailbox.
Get-MailboxStatistics | format-table DisplayName,LastLogoffTime,LastLogonTime,LastLoggedonUserAccount

Exchange 2007- Public Folder Permissions Example

Keep Reading ...

Seeing that Microsoft is attemping to move away from public folders and stopped providing easy GUI managment tools I found that this is the easiest way to modify permissions for a nested PF and change all child objects. Its simple and it works…
Get-PublicFolder -Identity “\(folder)\(folder)\” -recurse | Add-PublicFolderClientPermission -AccessRights owner (our desrired permission)
If your in IT [...]

Export List of Exchange 2007 mailbox sizes – Powershell script

Keep Reading ...

I have this script set as a sceduled task and runs daily on my companies Exchange 2007 servers. It helps to see not only the current sizes but to see if any mailboxes are getting out of control.
 
12345678910111213141516171819202122232425##############################################################
# Creates a file with all exchange 2007 mailboxes and sort by size
#
#
#
# Command, scheduled task or shortct [...]