Contents
- Cisco Anyconnect Powershell Download
- Powershell Install Cisco Anyconnect
- Uninstall Cisco Anyconnect Windows
Introduction
Powershell version 4+ (if you are using the below versions, just download from here.NET Framework 3.5+ CISCO AnyConnect Secure Mobility Client v4.6; Setup Process. Copy the script paste in Windows Powershell editor, read the comments and setup. I tested only Windows ENV with CISCO AnyConnect Secure Mobility Client v4.6. Powershell.exe -ExecutionPolicy Bypass -File 'C: ProgramData Cisco Cisco AnyConnect Secure Mobility Client Script UserRDP.ps1 Executing the script this way allows you to bypass the configured powershell execution policy on the local machine, allowing the script to run, while not needing to reconfigure the machine at all.
This document describes how to configure the Cisco Identity Services Engine (ISE) posture functionality when it is integrated with the Microsoft Windows Server Update Services (WSUS).
Note: When you access the network, you are redirected to the ISE for Cisco AnyConnect Secure Mobility Client Version 4.1 provisioning with a posture module, which checks the compliance status on the WSUS and installs the necessary updates in order for the station to be compliant. Once the station is reported as compliant, the ISE allows for full network access.
Prerequisites
Requirements
Cisco recommends that you have knowledge of these topics:
- Cisco ISE deployments, authentication, and authorization
- Basic knowledge about the way in which the ISE and the Cisco AnyConnect posture agent operate
- Configuration of the Cisco Adaptive Security Appliance (ASA)
- Basic VPN and 802.1x knowledge
- Configuration of the Microsoft WSUS
Components Used
The information in this document is based on these software and hardware versions:
Cisco Anyconnect Powershell Download
- Microsoft Windows Version 7
- Microsoft Windows Version 2012 with WSUS Version 6.3
- Cisco ASA Versions 9.3.1 and later
- Cisco ISE software Versions 1.3 and later
The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.
Configure
This section describes how to configure the ISE and related network elements.
Network Diagram
This is the topology that is used for the examples throughout this document:
Here is the traffic flow, as illustrated in the network diagram:
- The remote user connects through Cisco AnyConnect for VPN access to the ASA. This can be any type of unified access, such as an 802.1x/MAC Authentication Bypass (MAB) wired session that is terminated on the switch or a wireless session that is terminated on the Wireless LAN Controller (WLC).
- As a part of the authentication process, the ISE confirms that the posture status of the end station is not equal to compliant (ASA-VPN_quarantine authorization rule) and that the redirection attributes are returned in the Radius Access-Accept message. As a result, the ASA redirects all of the HTTP traffic to the ISE.
- The user opens a web browser and enters any address. After the redirection to the ISE, the Cisco AnyConnect 4 posture module is installed on the station. The posture module then downloads the policies from the ISE (requirement for WSUS).
- The posture module searches for Microsoft WSUS, and performs remediation.
- After successful remediation, the posture module sends a report to the ISE.
- The ISE issues a Radius Change of Authorization (CoA) that provides full network access to a compliant VPN user (ASA-VPN_compliant authorization rule).
Note: In order for the remediation to work (the ability to install Microsoft Windows updates on a PC), the user should have local administrative rights.
Microsoft WSUS
Note: A detailed configuration of the WSUS is out of the scope of this document. For details, refer to the Deploy Windows Server Update Services in Your Organization Microsoft documentation.
The WSUS service is deployed through the standard TCP port 8530. It is important to remember that for remediation, other ports are also used. This is why it is safe to add the IP address of WSUS to the redirection Access Control List (ACL) on the ASA (described later in this document).
The group policy for the domain is configured for Microsoft Windows updates and points to the local WSUS server:
These are the recommended updates that are enabled for granular policies that are based on different levels of severity:
The client-side targeting allows for far greater flexibility. The ISE can use posture policies that are based on the different Microsoft Active Directory (AD) computer containers. The WSUS can approve updates that are based on this membership.
ASA
Simple Secure Sockets Layer (SSL) VPN access for the remote user is employed (the details of which are out of the scope of this document).
Here is an example configuration:
It is important to configure an access-list on the ASA, which is used in order to determine the traffic that should be redirected to the ISE (for users that are not yet compliant):
Powershell Install Cisco Anyconnect
Only Domain Name System (DNS), ISE, WSUS, and Internet Control Message Protocol (ICMP) traffic is allowed for non-compliant users. All of the other traffic (HTTP) is redirected to the ISE for AnyConnect 4 provisioning, which is responsible for the posture and remediation.
ISE
Note: AnyConnect 4 provisioning and posture is out of the scope of this document. Refer to the AnyConnect 4.0 Integration with ISE Version 1.3 Configuration Example for more details, such as how to configure the ASA as a network device and install the Cisco AnyConnect 7 application.
Posture Remediation for WSUS
Complete these steps in order to configure the posture remediation for WSUS:
- Navigate to Policy > Conditions > Posture > Remediation Actions > Windows Server Update Services Remediation in order to create a new rule.
- Verify that the Microsoft Windows Updates setting is set to Severity Level. This part is responsible for detection if the remediation process is initiated.
The Microsoft Windows Update Agent then connects to the WSUS and checks whether there are any Critical updates for that PC that await installation:
Posture Requirement for WSUS
Navigate to Policy > Conditions > Posture > Requirements in order to create a new rule. The rule uses a dummy condition called pr_WSUSRule, which means that the WSUS is contacted in order to check for the condition when remediation is necessary (Critical updates).
Once this condition is met, the WSUS installs the updates that have been configured for that PC. These can include any type of updates, and also those with lower severity levels:
AnyConnect Profile
Configure the posture module profile, along with the AnyConnect 4 profile (as described in the AnyConnect 4.0 Integration with ISE Version 1.3 Configuration Example):
Client Provisioning Rules
Once the AnyConnect profile is ready, it can be referenced from the Client Provisioning policy:
The entire application, along with the configuration, is installed on the endpoint, which is redirected to the Client Provisioning portal page. AnyConnect 4 might be upgraded and an additional module (posture) installed.
Authorization Profiles
Create an authorization profile for redirection to the Client Provisioning profile:
Authorization Rules
This image shows the authorization rules:
For the first time, the ASA-VPN_quarantine rule is used. As a result, the Posture authorization profile is returned, and the endpoint is redirected to the Client Provisioning portal for AnyConnect 4 (with posture module) provisioning.
Once compliant, the ASA-VPN_compliant rule is used and full network access is allowed.
Verify
This section provides information that you can use in order to verify that you configuration works properly.
PC with Updated GPO Policies
The domain policies with the WSUS configuration should be pushed after the PC logs into the domain. This can occur before the VPN session is established (out of band) or after if the Start Before Logon functionality is used (it can be also used for 802.1x wired/wireless access).
Once the Microsoft Windows client has the correct configuration, this can be reflected from the Windows Update settings:
If needed, a Group Policy Object (GPO) refresh and Microsoft Windows Update Agent server discovery can be used:
Approve a Critical Update on the WSUS
The approval process can benefit from client-site targeting:
Resend the report with wuauclt if needed.
Check the PC Status on the WSUS
This image shows how to check the PC status on the WSUS:
One update should be installed for the next refresh with the WSUS.
VPN Session Established
After the VPN session is established, the ASA-VPN_quarantine ISE authorization rule is used, which returns the Posture authorization profile. As a result, the HTTP traffic from the endpoint is redirected for the AnyConnect 4 update and posture module provisioning:
At this point, the session status on the ASA indicates limited access with the redirection of the HTTP traffic to the ISE:
Posture Module Receives Policies from the ISE and Performs Remediation
The posture module receives the policies from the ISE. The ise-psc.log debugs show the requirement that is sent to the posture module:
The posture module automatically triggers the Microsoft Windows Update Agent to connect to the WSUS and download updates as configured in the WSUS policies (all automatically without any user intervention):
Note: Some of the updates might require a system restart.
Full Network Access
You will see this after the station is reported as compliant by the AnyConnect posture module:
The report is sent to the ISE, which reevaluates the policy and hits the ASA-VPN_compliant authorization rule. This provides full network access (via the Radius CoA). Navigate to Operations > Authentications in order to confirm this:
Uninstall Cisco Anyconnect Windows
The debugs (ise-psc.log) also confirm the compliance status, the CoA trigger, and the final settings for the posture:
Also, the ISE Detailed Posture Assessment report confirms that the station is compliant:
Note: The exact Media Access Control (MAC) address of the physical network interface on the Microsoft Windows PC is known because of the ACIDEX extensions.
Troubleshoot
There is currently no troubleshooting information available for this configuration.
Important Notes
This section provides some important information about the configuration that is described in this document.
Option Details for WSUS Remediation
It is important to differentiate the requirement condition from remediation. AnyConnect triggers the Microsoft Windows Update Agent to check the compliance, dependent upon the Validate Windows updates using remediation setting.
For this example, the Severity Level is used. With the Critical setting, the Microsoft Windows Agent checks whether there are any pending (not installed) critical updates. If there are, then remediation begins.
The remediation process might then install all of the critical and less important updates based on the WSUS configuration (updates approved for the specific machine).
With the Validate Windows updates using set as Cisco Rules, the conditions that are detailed in the requirement decide whether the station is compliant.
Windows Update Service
For deployments without a WSUS server, there is another remediation type that can be used called Windows Update Remediation:
This remediation type allows control over the Microsoft Windows Update settings and enables you to perform immediate updates. A typical condition that is used with this remediation type is pc_AutoUpdateCheck. This allows you to check whether the Microsoft Windows Update setting is enabled on the endpoint. If not, you can enable it and perform the update.
SCCM Integration
A new feature for the ISE Version 1.4 called patch management allows for integration with many third-party vendors. Dependent upon the vendor, multiple options are available for both the conditions and remediations.
For Microsoft, both the System Management Server (SMS) and the System Center Configuration Manager (SCCM) are supported.
Related Information
- Posture Services on the Cisco ISE Configuration Guide
- Cisco Identity Services Engine Administrator Guide, Release 1.4
- Cisco Identity Services Engine Administrator Guide, Release 1.3
- Deploy Windows Server Update Services in Your Organization
# Source www.cze.cz |
# This script is tested with 'Cisco AnyConnect Secure Mobility Client version 3.0.5080' |
# Run using %SystemRoot%system32WindowsPowerShellv1.0powershell.exe -ExecutionPolicy Bypass -File 'C:CiscoVPNAutoLogin.ps1' |
# VPN connection details |
[string]$CiscoVPNHost='vpn.example.com' |
[string]$Login='username' |
[string]$Password='password' |
[string]$vpncliAbsolutePath='C:Program Files (x86)CiscoCisco AnyConnect Secure Mobility Clientvpncli.exe' |
[string]$vpnuiAbsolutePath='C:Program Files (x86)CiscoCisco AnyConnect Secure Mobility Clientvpnui.exe' |
#**************************************************************************** |
#**** Please do not modify code below unless you know what you are doing **** |
#**************************************************************************** |
Add-Type-AssemblyName System.Windows.Forms -ErrorAction Stop |
# Set foreground window function |
# This function is called in VPNConnect |
Add-Type@' |
using System; |
using System.Runtime.InteropServices; |
public class Win { |
[DllImport('user32.dll')] |
[return: MarshalAs(UnmanagedType.Bool)] |
public static extern bool SetForegroundWindow(IntPtr hWnd); |
} |
'@-ErrorAction Stop |
# quickly start VPN |
# This function is called later in the code |
FunctionVPNConnect() |
{ |
Start-Process-FilePath $vpncliAbsolutePath-ArgumentList 'connect $CiscoVPNHost' |
$counter=0; $h=0; |
while($counter++-lt1000-and$h-eq0) |
{ |
sleep -m 10 |
$h= (Get-Process vpncli).MainWindowHandle |
} |
#if it takes more than 10 seconds then display message |
if($h-eq0){echo 'Could not start VPNUI it takes too long.'} |
else{[void] [Win]::SetForegroundWindow($h)} |
} |
# Terminate all vpnui processes. |
Get-Process|ForEach-Object {if($_.ProcessName.ToLower() -eq'vpnui') |
{$Id=$_.Id; Stop-Process$Id; echo 'Process vpnui with id: $Id was stopped'}} |
# Terminate all vpncli processes. |
Get-Process|ForEach-Object {if($_.ProcessName.ToLower() -eq'vpncli') |
{$Id=$_.Id; Stop-Process$Id; echo 'Process vpncli with id: $Id was stopped'}} |
# Disconnect from VPN |
echo 'Trying to terminate remaining vpn connections' |
start-Process-FilePath $vpncliAbsolutePath-ArgumentList 'disconnect'-wait |
#Connect to VPN |
echo 'Connecting to VPN address '$CiscoVPNHost' as user '$Login'.' |
VPNConnect |
# Write login and password |
[System.Windows.Forms.SendKeys]::SendWait('$Login{Enter}') |
[System.Windows.Forms.SendKeys]::SendWait('$Password{Enter}') |
# Start vpnui |
start-Process-FilePath $vpnuiAbsolutePath |
# Wait for keydown |
echo 'Press any key to continue ...' |
try{$x=$host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')}catch{} |
commented Jul 22, 2020
Is there any way to run this script in hidden mode? |
commented Jul 24, 2020
@Shikha1912, sorry, been a long time since I’ve used this but no, there wasn’t at the time. The script relies on launching the login form to send the username and password. It’s possible that a new client has a cleaner way to make thins work. Please let me know if you find a solution. |