Friday, December 27, 2013

Use PSEXEC to run a command against a list of machines and have it run a command from the machine

Start by creating a list of computers that need the command run on them (pclist.txt.).  Use the file copy command for /f %a in (pclist.txt) do copy /y \\server\share\file.bat \\%a\c$\ to copy the files to the machines in the pclist.txt.  In this example the file is copied to the root.  Next, from an elevated command prompt run:
psexec @pclist.txt c:\file.bat

This will execute the batch or exe file you copied to the remote machine on the remote machine. 
If you need to authenticate run:
psexec @pclist.txt -u domain\user c:\file.bat and it will prompt for a password.



copy files to multiple remote computers

To copy a file to multiple computers first create a txt file with all the computer names in it.  Place the file you want to copy in an accessible location for all the machines.  Run the following command:

for /f %a in (pclist.txt) do copy /y \\server\share\file.txt \\%a\c$\

This "should" copy the file to the machines listed assuming you have remote access.

Thursday, December 19, 2013

Exchange dynamic distribution groups based on security groups.

To create an exchange dynamic distribution group based on security group this can be done through powershell. The command specifies where to create the dynamic distribution group and what group the users will be a member of to pull the addresses from. The group name is “Dyn_universal” the security group is dyn_test, so any user in the OU test that is a member of dyn_test will get mail sent to the distribution group. New-DynamicDistributionGroup "Dyn_universal" -Alias "Dyn_universal" -OrganizationalUnit "OU=Test,DC=mydomain,DC=local" -RecipientFilter "MemberOfGroup -eq 'CN=dyn_test,OU=test,DC=mydomain,DC=local'"