RSend Project - Free Windows Instant Messenger for LAN and WAN

 


Blog: Assistance for Windows administrator


This blog contains materials relating to certain matters (mostly scripting) of Windows administration. All of them are based on personal experience and actually worked in practice in a production environment. Although some examples aren't perfect I hope they will be helpful anyway. If you have any questions, please write to info@rsend.ru, I'll try to respond as soon as possible.

Sincerely, Ihar Hrunt
MCSD App Builder
MCSA Windows Server 2012


1. Administration of Active Directory, Group Policy
    1.1. Examples of WMI filters
    1.2. Forced turning off computers at night

2. Startup GPO Visual Basic scripts
    2.1. VB script to install .NET Framework 3.5.1
    2.2. VB script to install Internet Explorer 8
    2.3. VB script to modify registry with .reg file
    2.4. VB script to migrate clients from Citrix Presentation Server 4.5 to XenApp 6.5
    2.5. VB script to install Windows Installer 4.5
    2.6. VB script to install MS Office Compatibility Pack
    2.7. VB script to install Windows Live Mail
    2.8. VB script to install UltraVNC with MV2 driver

3. General information about Powershell scripts
    3.1. Ps1 script to check if there are duplicate IP addresses in DNS
    3.2. Ps1 script to compare computers in Active Directory and WSUS
    3.3. Ps1 script to reset WSUS authorization
    3.4. Ps1 script to compare OUs and shadow groups members
    3.5. PS1 script + C# application to disable/enable user accounts with schedule sheet
    3.6. PS1 script to get LastLogon and PwdLastSet attributes
    3.7. PS1 script to check directories security permissions

4. General information about Powershell scripts & Windows Remoting
    4.1. WinRM Ps1 script to get event logs information from computers
    4.2. WinRM Ps1 script to get disk C free space of computers
    4.3. WinRM Ps1 script to get members of local admin groups
    4.4. WinRM Ps1 script to check if firewall is enabled in domain profiles
    4.5. WinRM Ps1 script to check if process (RSendClient.exe) is running




1. Administration of Active Directory, Group Policy

Unfortunately due to the lack of Windows 7 or 8 in English I can not yet publish screenshots of group policy objects, which I think might be useful in your work. I hope to fix it in the near future.


1.1 Examples of WMI filters

Group policy WMI filters are available in domain controller Windows Server 2008 and above (you can use WMI filtering in Windows Server 2003 but only in startup/logon scripts). They make GPO maintenance easier especially when you have mix of operation systems in your network. If you pay more attention to WMI filtering you see how granular your GPO targeting can be. Here are a few simple examples that are used to determine the types of operating systems.

published: 2013-03-05



1.2 Forced turning off computers at night

In DC 2008 and above you can do it this way. Create a GPO. In the Computer Configuration -> Preferences folder -> Control Panel Settings -> Scheduled Tasks create a new task (or multiple tasks depending on your needs) with command "shutdown -s -f -t 180" and start time after working hours. Check if the computer is idle for specified period of time before turning off. Repeat the task after specified period of time if the computer wasn't idle. Use local or domain admin priveleges to run the task. With WMI filter or Targeting you can exclude from the target computers by type of operating system or computer name.

published: 2013-03-05




2. Startup GPO Visual Basic scripts


2.1. VB script to install .NET Framework 3.5.1

If you need to install .Net Framework 3.5.1 on Windows XP then you can spend some time and efforts to prepare several .msi files (2.0, 3.0, 3.5) from dotnetfx35 installer or use much ease way - startup vbscript with silent instalation.

published: 2013-03-05



2.2. VB script to install Internet Explorer 8

Take your attention to /forestart key. Internet Explorer 8 requires to restart machine after installation.

published: 2013-03-05



2.3. VB script to modify registry with .reg file

If you need to add or modify many keys and values in registry then you can save your time if you make snapshot of registry (.reg file) and apply it via startup vbscript as showed below (with your small modifications).

published: 2013-03-05



2.4. VB script to migrate clients from Citrix Presentation Server 4.5 to XenApp 6.5

This script uninstalls the Citrix Program Neighborhood Client (if exists), then installs CitrixOnlinePluginFull 12.3 and TninPrint Client 8.6 for ICA connection, and last writes address of the farm (ServerURL parameter) to the registry. Please take notice to the fragment of the script (Uninstall Citrix Program Neighborhood Client) that allows you to uninstall programs with a complex set of parameters in UninstallString. To install ThinPrint Client on computers with Windowx XP you have to install Windows Installer 4.5 first (how to do that please see the vbscript below).

published: 2013-04-24



2.5. VB script to install Windows Installer 4.5

After installation of this package, the version of Windows Installer on the system will be upgraded to 4.5.

published: 2013-04-24



2.6. VB script to install MS Office Compatibility Pack

By installing the Compatibility Pack along-side of Microsoft Office XP, or Office 2003, you will be able to open, edit, and create files using the formats that are used by Microsoft Office 2007 (docx, xlsx and pptx).

published: 2013-04-24



2.7. VB script to install Windows Live Mail

Windows Live Mail is a freeware email client from Microsoft. It is the successor to Outlook Express on Windows XP and Windows Mail on Windows Vista. The application is available for download via the Windows Essentials 2012 suite. This script installs only Mail feature of suite.

published: 2013-04-24



2.8. VB script to install UltraVNC with MV2 driver

Constant lack of time... I hope I'll find the time to publish detailed description of preliminary steps of the configuration UltraVNC for installation via GPO...

published: 2013-06-10




3. General information about Powershell scripts

If you are planning to run a Powershell script with Active Directory commandlets on a machine (for example, workstation) that doesn't have AD role then you need to do some preliminary steps. Please ask Microsoft or Goggle for details.
Some scripts are running with use of scheduler and result is being sent via email. Other scripts are running with use of PowerGUI (graphical user interface and script editor for PowerShell), where you can filter, format, export scripts' results and do more other useful things (for example, work with Active Directory or manage computers in your network).




3.1. Ps1 script to check if there are duplicate IP addresses in DNS

Maybe regular using of this script will push you to pay more attention to how to properly assigned static IP addesses in your network, or maybe you will think to review the period of DHCP lease time (for example, we increased it twice) or DNS scavenging ...

published: 2013-03-20



3.2. Ps1 script to compare computers in Active Directory and WSUS

To run this script successfully you need to install either WSUS administration console or Remote System Administration Tools (RSAT) on your computer, and then configure access to WSUS.

published: 2013-03-20



3.3. Ps1 script to reset WSUS authorization

If some of your computers aren't listed in WSUS the first step is to do resetauthorization. One of the reason is cloned computers (duplicate registry values SusClientId and/or SusClientIdValidation). This script will help to automate this work. To save your time you can use Windows Remoting to work out group of computers remotely .

published: 2013-03-20



3.4. Ps1 script to compare OUs and shadow groups members

If you actively use a domain shadow groups then this script will help you to monitor the membership of the organizational units and shadow groups. To do this, run the script manually or using the scheduler.

published: 2013-03-20



3.5. Ps1 script + C# application to disable/enable user accounts with schedule sheet

In some companies, there is a rule according to which the accounts of staff leaving on vacation must be disabled. This work performed by system administrators on the basis of documents from the Department of Human Resources. After returning from vacation the staff call system administrators to enable the account. To reduce the time spent on these activities was developed the project based on Powershell script and C # application (graphical user interface).

How it works. The script ADUserManager.ps1 runs every night using a scheduled task with domain administrator privileges. The script is doing synchronization of the data file "data.txt" with user accounts from Active Directory (disabled accounts in Active Directory have the same status in the file "data.txt") .
With ADUserManager.exe (graphical user interface in C #, should be in the same directory as the file "data.txt") administrator specifies start date and/or expiration date for disabling user accounts. These data are stored in a file "data.txt". Based on these data, the script ADUserManager.ps1 disables/enables user accounts and synchronizes the file "data.txt" with Active Directory (if there are new or deleted user accounts). Report.log logs all actions regarding accounts disabling/enabling and any errors if they occur.





Script configuration .
Parameter $OU - this is the point to begin searching for user accounts in Active Directory. Parameter $GroupDomainAdmin is used to exclude members of "Domain Administrators" group from processing if $OU search starts from the top of domain "DC = yourdomain, DC = com".

Download Ps1 script and C# application in ADUserManager.zip   (10 kb, checked by Kaspersky Antivirus)
Download VS2012 C# solution in ADUserManagerSource.zip   (28 kb, checked by Kaspersky Antivirus)

published: 2013-03-20



3.6. PS1 script to get LastLogon and PwdLastSet attributes

This script is used to control if there are stale users accounts in Active Directory.

published: 2013-03-20



3.7. PS1 script to check directories security permissions

This is a simple script provides information about directories security permissions on the drive or selected directory. For a quick audit of a large number of directories I think it is more convenient than using standard Windows tool.

published: 2013-03-20




4. General information about Powershell scripts & Windows Remoting

Windows Remoting (WinRM) is useful technologies that can can be used by administrators to manage computers in network. With WinRM you can get any information from computers. For example, monitoring computers health by using logs information. If you are planning to run a Powershell scripts with WinRM then you need to do some preliminary steps. All these steps can be done either manually or with group policy. I'm going to publish screenshots of these GPO in the nearest future. Now you can find how to do that at Microsoft or ask Goggle.
A couple of comments regarding these scripts. You can notice that all scripts in this section are the same except for the two part - $scriptblock and Select-Object of Start-Invoke function. Second, all these scripts use invoke-command with -AsJob and -Trottle parameters to provide simultaneous execution of the $scriptblock by remote computers. That helps to save much time while getting result (500 computer running the script from about 5 to 15 minutes depending on the complexity of the executable code). Third, again I advise you to use PowerGUI (graphical user interface and script editor for PowerShell) to run these scripts, where you can filter, format, export scripts' results and do more other useful things.
And one more thing, to run these scripts you have to use domain admin account or add your account to local administrator group on computers (you can do it via GPO).




4.1. WinRM Ps1 script to get event logs information from computers

To get required logs information you can modify several parameters: first - log type (System, Application, Security), second - days offset, third - entry type (error, warning, ... ).

published: 2013-03-20



4.2. WinRM Ps1 script to get disk C free space of computers

published: 2013-03-20



4.3. WinRM Ps1 script to get members of local admin groups

To work this script correctly you need to specify a name of local administrator group in a language of your Microsoft Windows.

published: 2013-03-20



4.4. WinRM Ps1 script to check if firewall is enabled in domain profiles

published: 2013-03-20



4.5. WinRM Ps1 script to check if process (RSendClient.exe) is running

published: 2013-03-20