diff --git a/Windows-Samples/README.md b/Windows-Samples/README.md index 93a64590..edafe930 100644 --- a/Windows-Samples/README.md +++ b/Windows-Samples/README.md @@ -6,6 +6,7 @@ This section of the **AirWatch-samples** repository contains samples relating to Some examples of items to submit for consideration and use by the community: - Custom XML Profile Payloads (use [VMware Policy Builder](https://VMwarePolicyBuilder.com) for easy Windows 10 Custom XML generation) +- Workspace ONE Sensors Samples - Scripts for Product Provisioning - Scripts to use as helpful tools diff --git a/Windows-Samples/Sensors/README.md b/Windows-Samples/Sensors/README.md new file mode 100644 index 00000000..bb1b1e42 --- /dev/null +++ b/Windows-Samples/Sensors/README.md @@ -0,0 +1,23 @@ +# Custom Attributes + +## Overview +- **Authors**: Robert Terakedis, John Richards +- **Email**: rterakedis@vmware.com, jrichards@vmware.com +- **Date Created**: 6/8/2017 +- **Supported Platforms**: AirWatch version 9.0 +- **Tested on macOS Versions**: macOS El Capitan, macOS Sierra + +## Purpose +These sample custom attributes contain command lines or scripts that can be used in a Custom Attribute payload to report back information about macOS to AirWatch. + +## Required Changes/Updates +None + +## Change Log +- 6/8/2017: Created Initial File +- 7/20/2017: Cleanup and added more CA's +- 2/1/2018: Added more CA's + + +## Additional Resources +None diff --git a/Windows-Samples/Sensors/battery_charging_status.ps1 b/Windows-Samples/Sensors/battery_charging_status.ps1 new file mode 100644 index 00000000..f356c1ef --- /dev/null +++ b/Windows-Samples/Sensors/battery_charging_status.ps1 @@ -0,0 +1,11 @@ +# Returns "Charging" or "Not Charging" if the battery is charging or not +# Return Type: String +# Execution Context: User +$charge_status = (Get-CimInstance win32_battery).batterystatus +$charging = @(2,6,7,8,9) +if($charging -contains $charge_status[0] -or $charging -contains $charge_status[1] ) +{ + echo "Charging" + }else{ + echo "Not Charging" +} \ No newline at end of file diff --git a/Windows-Samples/Sensors/battery_estimated_charge_remaining.ps1 b/Windows-Samples/Sensors/battery_estimated_charge_remaining.ps1 new file mode 100644 index 00000000..df38e18c --- /dev/null +++ b/Windows-Samples/Sensors/battery_estimated_charge_remaining.ps1 @@ -0,0 +1,5 @@ +# Returns the estimated remaining charge on the battery +# Return Type: Integer +# Execution Context: User +$battery_remain=(Get-WmiObject win32_battery).estimatedChargeRemaining | Measure-Object -Average | Select-Object -ExpandProperty Average +echo $battery_remain \ No newline at end of file diff --git a/Windows-Samples/Sensors/battery_max_capacity.ps1 b/Windows-Samples/Sensors/battery_max_capacity.ps1 new file mode 100644 index 00000000..3b782c1f --- /dev/null +++ b/Windows-Samples/Sensors/battery_max_capacity.ps1 @@ -0,0 +1,6 @@ +# Returns the max charge capacity of the batteries +# Return Type: Integer +# Execution Context: User +$max_capacity = (Get-WmiObject -Class "BatteryFullChargedCapacity" -Namespace "ROOT\WMI").FullChargedCapacity | Measure-Object -Sum | Select-Object -ExpandProperty Sum +echo $max_capacity + diff --git a/Windows-Samples/Sensors/bios_secure_boot.ps1 b/Windows-Samples/Sensors/bios_secure_boot.ps1 new file mode 100644 index 00000000..693f74c5 --- /dev/null +++ b/Windows-Samples/Sensors/bios_secure_boot.ps1 @@ -0,0 +1,6 @@ +# Returns True/False if Secure Boot is Enabled or Disabled +# Return Type: Boolean +# Execution Context: Admin +$bios = Confirm-SecureBootUEFI +echo $bios + diff --git a/Windows-Samples/Sensors/bios_serial_number.ps1 b/Windows-Samples/Sensors/bios_serial_number.ps1 new file mode 100644 index 00000000..65bcbb01 --- /dev/null +++ b/Windows-Samples/Sensors/bios_serial_number.ps1 @@ -0,0 +1,5 @@ +# Returns the device's serial number +# Return Type: String +# Execution Context: User +$os=Get-WmiObject Win32_bios -ComputerName $env:$computername -ea silentlycontinue +echo $os.SerialNumber \ No newline at end of file diff --git a/Windows-Samples/Sensors/bios_smbios_present.ps1 b/Windows-Samples/Sensors/bios_smbios_present.ps1 new file mode 100644 index 00000000..9bb25248 --- /dev/null +++ b/Windows-Samples/Sensors/bios_smbios_present.ps1 @@ -0,0 +1,5 @@ +# Returns True/False whether the SMBIOS is Present +# Return Type: Boolean +# Execution Context: User +$bios=Get-WmiObject Win32_bios -ComputerName $env:computername -ea silentlycontinue +echo $bios.SMBIOSPresent \ No newline at end of file diff --git a/Windows-Samples/Sensors/bios_smbios_version.ps1 b/Windows-Samples/Sensors/bios_smbios_version.ps1 new file mode 100644 index 00000000..8b81f88b --- /dev/null +++ b/Windows-Samples/Sensors/bios_smbios_version.ps1 @@ -0,0 +1,5 @@ +# Returns the SMBIOS Version +# Return Type: String +# Execution Context: User +$bios=Get-WmiObject Win32_bios -ComputerName $env:computername -ea silentlycontinue +echo $bios.SMBIOSBIOSVersion \ No newline at end of file diff --git a/Windows-Samples/Sensors/bios_status.ps1 b/Windows-Samples/Sensors/bios_status.ps1 new file mode 100644 index 00000000..a00a02ce --- /dev/null +++ b/Windows-Samples/Sensors/bios_status.ps1 @@ -0,0 +1,7 @@ +# Returns the BIOS Status +# Statuses include: "OK", "Degraded", and "Pred Fail" (an element, such as a SMART-enabled hard disk drive, may be functioning properly but predicting a failure in the near future). Nonoperational statuses include: "Error", "Starting", "Stopping", and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is online, yet the managed element is neither "OK" nor in one of the other states. +# Return Type: String +# Execution Context: User +$bios=Get-WmiObject Win32_bios -ComputerName $env:computername -ea silentlycontinue +echo $bios.Status + diff --git a/Windows-Samples/Sensors/os_cpu_usage.ps1 b/Windows-Samples/Sensors/os_cpu_usage.ps1 new file mode 100644 index 00000000..c7564a80 --- /dev/null +++ b/Windows-Samples/Sensors/os_cpu_usage.ps1 @@ -0,0 +1,6 @@ +# Returns load capacity of each processor, averaged to the last second. +# Return Type: Integer +# Execution Context: User +$cpu_usage=Get-WmiObject win32_processor | Select-Object -ExpandProperty LoadPercentage +echo $cpu_usage + diff --git a/Windows-Samples/Sensors/os_cpu_usage_processname.ps1 b/Windows-Samples/Sensors/os_cpu_usage_processname.ps1 new file mode 100644 index 00000000..7749cc8a --- /dev/null +++ b/Windows-Samples/Sensors/os_cpu_usage_processname.ps1 @@ -0,0 +1,7 @@ +# Returns the average amount of processor time that the process has used on all processors, in seconds. +# Return Type: Integer +# Execution Context: User +# change mcshield to your process name +$cpu_usage=get-process mcshield |measure-object -property CPU -Average |select-object -ExpandProperty Average +echo ([System.Math]::Round($cpu_usage)) + diff --git a/Windows-Samples/Sensors/os_java_version.ps1 b/Windows-Samples/Sensors/os_java_version.ps1 new file mode 100644 index 00000000..511c1351 --- /dev/null +++ b/Windows-Samples/Sensors/os_java_version.ps1 @@ -0,0 +1,5 @@ +# Returns Java Version e.g. 8.0.1910.12 +# Return Type: String +# Execution Context: User +$javaver=(Get-Command java | Select-Object -ExpandProperty Version).toString() +echo $javaver \ No newline at end of file diff --git a/Windows-Samples/Sensors/os_memory_physical_usage.ps1 b/Windows-Samples/Sensors/os_memory_physical_usage.ps1 new file mode 100644 index 00000000..8324920b --- /dev/null +++ b/Windows-Samples/Sensors/os_memory_physical_usage.ps1 @@ -0,0 +1,7 @@ +# Returns used phsyical memory in kilobytes +# Return Type: Integer +# Execution Context: User +$os = Get-WmiObject win32_OperatingSystem +$used_memory = $os.totalvisiblememorysize - $os.freephysicalmemory +echo $used_memory + diff --git a/Windows-Samples/Sensors/os_memory_usage_processname.ps1 b/Windows-Samples/Sensors/os_memory_usage_processname.ps1 new file mode 100644 index 00000000..985893ac --- /dev/null +++ b/Windows-Samples/Sensors/os_memory_usage_processname.ps1 @@ -0,0 +1,8 @@ +# Returns the average amount of non-paged and paged memory that the process is using, in kilobytes. +# Return Type: Integer +# Execution Context: User +# change mcshield to your process name +$PM = get-process mcshield |Measure-object -property PM -Average|Select-Object -ExpandProperty Average +$NPM = get-process mcshield |Measure-object -property NPM -Average|Select-Object -ExpandProperty Average +echo [System.Math]::Round(($PM+$NPM)/1KB) + diff --git a/Windows-Samples/Sensors/os_memory_virtual_usage.ps1 b/Windows-Samples/Sensors/os_memory_virtual_usage.ps1 new file mode 100644 index 00000000..f9a5b9cc --- /dev/null +++ b/Windows-Samples/Sensors/os_memory_virtual_usage.ps1 @@ -0,0 +1,7 @@ +# Returns used virutal memory in kilobytes +# Return Type: Integer +# Execution Context: User +$os=Get-WmiObject win32_OperatingSystem +$used_memory=$os.totalvirtualmemorysize - $os.freevirtualmemory +echo $used_memory + diff --git a/Windows-Samples/Sensors/os_network_interface_name.ps1 b/Windows-Samples/Sensors/os_network_interface_name.ps1 new file mode 100644 index 00000000..0a9994e4 --- /dev/null +++ b/Windows-Samples/Sensors/os_network_interface_name.ps1 @@ -0,0 +1,7 @@ +# Returns the name (description) of the active network interface +# Return Type: String +# Execution Context: User +$properties = @(‘Name’,’InterfaceDescription’) +$physical_adapter = get-netadapter -physical | where status -eq "up" |select-object -Property $properties +echo $physical_adapter.InterfaceDescription + diff --git a/Windows-Samples/Sensors/os_network_usage.ps1 b/Windows-Samples/Sensors/os_network_usage.ps1 new file mode 100644 index 00000000..03dc0450 --- /dev/null +++ b/Windows-Samples/Sensors/os_network_usage.ps1 @@ -0,0 +1,6 @@ +# Returns used network in bytes +# Return Type: Integer +# Execution Context: User +$Total_bytes=Get-WmiObject -class Win32_PerfFormattedData_Tcpip_NetworkInterface |Measure-Object -property BytesTotalPersec -Average |Select-Object -ExpandProperty Average +echo ([System.Math]::Round($Total_bytes)) + diff --git a/Windows-Samples/Sensors/os_network_wifi_present.ps1 b/Windows-Samples/Sensors/os_network_wifi_present.ps1 new file mode 100644 index 00000000..ab6de1a9 --- /dev/null +++ b/Windows-Samples/Sensors/os_network_wifi_present.ps1 @@ -0,0 +1,6 @@ +# Returns True/False if Wifi is present or not +# Return Type: Boolean +# Execution Context: User +$wireless = Get-WmiObject -class Win32_NetworkAdapter -filter "netconnectionid like 'Wi-Fi%'" +if($wireless){echo $true} +else {echo $false} \ No newline at end of file diff --git a/Windows-Samples/Sensors/os_power_plan_description.ps1 b/Windows-Samples/Sensors/os_power_plan_description.ps1 new file mode 100644 index 00000000..5a3cccd9 --- /dev/null +++ b/Windows-Samples/Sensors/os_power_plan_description.ps1 @@ -0,0 +1,5 @@ +# Returns the description of the Power Plan +# Return Type: String +# Execution Context: Admin +$powerplan=get-wmiobject -namespace "root\cimv2\power" -class Win32_powerplan | where {$_.IsActive} +echo $powerplan.Description \ No newline at end of file diff --git a/Windows-Samples/Sensors/os_power_plan_name.ps1 b/Windows-Samples/Sensors/os_power_plan_name.ps1 new file mode 100644 index 00000000..fc9445eb --- /dev/null +++ b/Windows-Samples/Sensors/os_power_plan_name.ps1 @@ -0,0 +1,5 @@ +# Returns the name of the Power Plan +# Return Type: String +# Execution Context: Admin +$powerplan=get-wmiobject -namespace "root\cimv2\power" -class Win32_powerplan | where {$_.IsActive} +echo $powerplan.ElementName \ No newline at end of file diff --git a/Windows-Samples/Sensors/os_powershell_version.ps1 b/Windows-Samples/Sensors/os_powershell_version.ps1 new file mode 100644 index 00000000..90eed80d --- /dev/null +++ b/Windows-Samples/Sensors/os_powershell_version.ps1 @@ -0,0 +1,6 @@ +# Returns the PowerShell Version in Major.Minor.Build.Revision format +# Return Type: String +# Execution Context: User +$ps = $PSVersionTable.PSVersion +echo "$($ps.Major).$($ps.Minor).$($ps.Build).$($ps.Revision)" + diff --git a/Windows-Samples/Sensors/os_process_running.ps1 b/Windows-Samples/Sensors/os_process_running.ps1 new file mode 100644 index 00000000..83ac6ff4 --- /dev/null +++ b/Windows-Samples/Sensors/os_process_running.ps1 @@ -0,0 +1,11 @@ +# Returns True/False if Process is Running or Not. +# Return Type: Boolean +# Execution Context: User +# change mcshield to your process name +$process = Get-Process mcshield -ea SilentlyContinue +if($process){ + echo $true + }else{ + echo $false +} + diff --git a/Windows-Samples/Sensors/system_date.ps1 b/Windows-Samples/Sensors/system_date.ps1 new file mode 100644 index 00000000..29cbb7d1 --- /dev/null +++ b/Windows-Samples/Sensors/system_date.ps1 @@ -0,0 +1,5 @@ +# Returns the system's date and time +# Return Type: Date/Time +# Execution Context: User +$date_current = get-Date -DisplayHint Date +echo $date_current \ No newline at end of file diff --git a/Windows-Samples/Sensors/tpm_locked_out.ps1 b/Windows-Samples/Sensors/tpm_locked_out.ps1 new file mode 100644 index 00000000..0d7b4d6a --- /dev/null +++ b/Windows-Samples/Sensors/tpm_locked_out.ps1 @@ -0,0 +1,5 @@ +# Returns True/False whether the TPM is locked out +# Return Type: Boolean +# Execution Context: Admin +$tpm=get-tpm +echo $tpm.LockedOut \ No newline at end of file diff --git a/Windows-Samples/Sensors/tpm_lockout_heal_time.ps1 b/Windows-Samples/Sensors/tpm_lockout_heal_time.ps1 new file mode 100644 index 00000000..604578a6 --- /dev/null +++ b/Windows-Samples/Sensors/tpm_lockout_heal_time.ps1 @@ -0,0 +1,5 @@ +# Returns time (string) for how long the TPM will be locked out, if it locks +# Return Type: String +# Execution Context: Admin +$tpm=get-tpm +echo $tpm.LockoutHealTime \ No newline at end of file diff --git a/Windows-Samples/Sensors/tpm_present.ps1 b/Windows-Samples/Sensors/tpm_present.ps1 new file mode 100644 index 00000000..e0b3fe22 --- /dev/null +++ b/Windows-Samples/Sensors/tpm_present.ps1 @@ -0,0 +1,5 @@ +# Returns True/False whether there is a TPM on the current computer +# Return Type: Boolean +# Execution Context: Admin +$tpm=get-tpm +echo $tpm.TpmPresent \ No newline at end of file diff --git a/Windows-Samples/Sensors/tpm_ready.ps1 b/Windows-Samples/Sensors/tpm_ready.ps1 new file mode 100644 index 00000000..f1e84ace --- /dev/null +++ b/Windows-Samples/Sensors/tpm_ready.ps1 @@ -0,0 +1,5 @@ +# Returns True/False whether TPM is Ready to be used +# Return Type: Boolean +# Execution Context: Admin +$tpm=get-tpm +echo $tpm.TpmReady \ No newline at end of file