PowerShell – Install Patches Remotely

email me

This is a script I wrote to remotely install patches on servers. The servers.txt contains the server names (I used IP addresses). You will need psexec and appropriate access to the servers.

Clear-Host

$ErrorActionPreference = 'silentlycontinue'

$LocalHotFixPath = 'D:\Patches\'

$SvrList = Get-Content 'D:\Patches\servers.txt'

$HotFixes = @(
# seperate KBs using commas
'KB4499175-x64.msu'
)

foreach ($Server in $SvrList)
{
$Reboot = $False
$RemoteHotFixPath = "\\$Server\c$\Windows\Temp\"

# Install each hotfix
foreach ($HotFix in $HotFixes)
{
Write-Host "Processing $HotFix on $Server..."
$HotFixPath = "$LocalHotFixPath$HotFix"

# Copy file
Copy-Item $HotFixPath $RemoteHotFixPath
# Launch remote install
& C:\Windows\PsExec -s \\$Server wusa C:\Windows\Temp\$HotFix /quiet /norestart

# Clear session
$RemoteHotFixPath = ""
$HotFix = ""
Write-Host "`n`n"

if ($LastExitCode -eq 3010) {
$Reboot = $true
}
}

if($Reboot) # write message
{
Write-Host "$Server needs a restart."
}
}


Notes

https://www.catalog.update.microsoft.com/Search.aspx?q=KB4499175

 

tags: MrNetTek

Adobe Creative Cloud – 4.8.1.435

email me

Download

New Creative Cloud app is available here:

http://ccmdl.adobe.com/AdobeProducts/KCCC/1/win32/ACCCx4_8_1_435.zip

 

Some things to note:

  • Adobe is changing how enterprise installs are done, opting to move app control and app updates to the cloud. I’m guessing this is to reduce piracy, while enforcing updates.
  • The app set-up.exe (from the download) will work, however is no longer 100% silent, and cannot be completely automated. {Adobe, say it ain’t so…}
  • For a fully automated enterprise deployment, you need to log into Adobe, and access the Cloud Admin Console. Appropriate rights are required to view the Admin Console. From there, you can create a downloadable, enterprise deployment package.

 

Workaround

Rather than being forced to use the online Admin Console, which requires licensing and rights, try using the Build folder I captured, minus the latest app update.

  • Create a Build folder.
  • Download the Build.zip.
  • Extract contents of Build.zip to Build folder.
  • Download the latest desktop app from Adobe.
  • Extract contents of desktop app.
  • Rename set-up.exe to set-up.dat.
  • Copy contents of desktop app to Build > ASU.
  • Create your own package, calling the setup.exe. For my package, I used a self-extracting EXE in WinRar, pointing to the setup.exe.


Build.zip file


ASU folder


Self-extracting EXE


Prepare for awesomeness

 

 

L e g a c y   S u p p o r t

Silent Install

Use a set-up.exe from a previous version to get around the initial Cloud setup.

set-up.exe –silent –ADOBEINSTALLDIR=”C:\Program Files (x86)\Adobe\CreativeCloud” –INSTALLLANGUAGE=en_GB

 

Silent Uninstall

Found the silent option inside the EXE…

“C:\Program Files (x86)\Adobe\Adobe Creative Cloud\Utils\Creative Cloud Uninstaller.exe” -u

 

Screenshot

 

Notes

Check out the -pid parameter

https://helpx.adobe.com/download-install/kb/creative-cloud-desktop-app-download.html

 

tags: MrNetTek

Citrix Workspace – 19.4.1.41 (1904.1)

email me

Download

A new Citrix Workspace client is available here:

https://www.citrix.com/downloads/workspace-app/windows/workspace-app-for-windows-latest.html

 

Size

118 MB


Silent Install

setup.exe /rcu /silent STORE0=”Store;https://mycitrix.umc.edu/Citrix/ummcWeb/discovery;Store”


Silent Uninstall

setup.exe /silent /uninstall


Registry

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Citrix

 

Notes

Product Documentation

Citrix moves from Receiver to Workspace

https://www.citrix.com/products/receiver.html

 

tags: MrNetTek

Windows – Short Name Issues with Progra~1 and Progra~2

email me

If you receive the short-path missing message, or the short paths just aren’t working, use fsutil to fix it:

 

from the admin command prompt…


Enable Short Name Creation

fsutil 8dot3name set c: 0


Add Short Names

fsutil file setshortname “C:\Program Files” PROGRA~1

fsutil file setshortname “C:\Program Files (x86)” PROGRA~2

* if you have issues, try this in safe mode


Notes

Check for short names

dir /X

 

Create a junction

mklink /J “C:\PROGRA~1” “C:\Program Files
mklink /J “C:\PROGRA~2” “C:\Program Files (x86)”

 

tags: MrNetTek

PowerShell – Return Installed Software

email me

Display Name

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |
Select-Object DisplayName


Display Name with Uninstall String

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |
Select-Object DisplayName,UninstallString


GridView

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |
Where-Object { $_.DisplayName } |
Select-Object DisplayName, DisplayVersion, Publisher, UninstallString |
Out-GridView

 

tags: MrNetTek

PowerShell – Return Product Key

email me

function Get-ProductKey {
$map="BCDFGHJKMPQRTVWXY2346789"
$value = (get-itemproperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").digitalproductid[0x34..0x42]
$ProductKey = ""

for ($i = 24; $i -ge 0; $i--) {
$r = 0
for ($j = 14; $j -ge 0; $j--) {
$r = ($r * 256) -bxor $value[$j]
$value[$j] = [math]::Floor([double]($r/24))
$r = $r % 24
}
$ProductKey = $map[$r] + $ProductKey
if (($i % 5) -eq 0 -and $i -ne 0) {
$ProductKey = "-" + $ProductKey
}
}
$ProductKey
}

Get-ProductKey

 

tags: MrNetTek

PowerShell – Return IP, Subnet, Gateway, and DNS

email me

Function Get-IPObject
{
Get-WmiObject -class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = $true"
}

Function Format-netData($objIP)
{
"IP: " + $objIP.IPAddress[0]
"Subnet: " + $objIP.IPSubNet[0]
"GateWay: " + $objIP.DefaultIPGateway[0]
"DNS: " + $objIP.DNSServerSearchOrder[0]
}

Clear-Host

$Data = Get-IPObject

Format-netData($Data)

 


Notes

Performing Networking Tasks (Microsoft Docs)

 

DHCPEnabled :
IPAddress :
DefaultIPGateway :
DNSDomain :
ServiceName :
Description :
Index :

 

Try this

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName . | Select-Object -Property [a-z]* -ExcludeProperty IPX*,WINS*

DHCPLeaseExpires :
Index :
Description :
DHCPEnabled :
DHCPLeaseObtained :
DHCPServer :
DNSDomain :
DNSDomainSuffixSearchOrder :
DNSEnabledForWINSResolution :
DNSHostName :
DNSServerSearchOrder :
DomainDNSRegistrationEnabled :
FullDNSRegistrationEnabled :
IPAddress :
IPConnectionMetric :
IPEnabled :
IPFilterSecurityEnabled :
ArpAlwaysSourceRoute :
ArpUseEtherSNAP :
Caption :
DatabasePath :
DeadGWDetectEnabled :
DefaultIPGateway :
DefaultTOS :
DefaultTTL :
ForwardBufferMemory :
GatewayCostMetric :
IGMPLevel :
InterfaceIndex :
IPPortSecurityEnabled :
IPSecPermitIPProtocols :
IPSecPermitTCPPorts :
IPSecPermitUDPPorts :
IPSubnet :
IPUseZeroBroadcast :
KeepAliveInterval :
KeepAliveTime :
MACAddress :
MTU :
NumForwardPackets :
PMTUBHDetectEnabled :
PMTUDiscoveryEnabled :
ServiceName :
SettingID :
TcpipNetbiosOptions :
TcpMaxConnectRetransmissions :
TcpMaxDataRetransmissions :
TcpNumConnections :
TcpUseRFC1122UrgentPointer :
TcpWindowSize :
Scope :
Path :
Options :
ClassPath :
Properties :
SystemProperties :
Qualifiers :
Site :
Container :

 

tags: MrNetTek

PowerShell – Test Admin Status of Current User

email me

Function Test-AdminStatus
{
$WinIdentity = [Security.Principal.WindowsIdentity]::GetCurrent()
$WinPrincipal = New-Object Security.Principal.WindowsPrincipal $WinIdentity
#ACCOUNT
$WinPrincipal.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

Clear-Host

# Test Function
if (Test-AdminStatus) {"$env:UserName : True"} Else {"$env:UserName : False"}


Output

 


Notes

[enum]::getnames("security.principal.WindowsBuiltInRole")

 

Other accounts you can test for

User
Guest
PowerUser
AccountOperator
SystemOperator
PrintOperator
BackupOperator
Replicator

 

tags: MrNetTek

PowerShell – Export AD Users to CSV

email me

Import-Module ActiveDirectory
Get-ADUser -Filter * -Properties * | Select-Object Name, DisplayName, Title, EmailAddress | export-csv -path c:\AD_Report\data.csv

 


Notes

Get-ADUser

AccountExpirationDate
accountExpires
AccountLockoutTime
AccountNotDelegated
AllowReversiblePasswordEncryption
AuthenticationPolicy
AuthenticationPolicySilo
BadLogonCount
badPasswordTime
badPwdCount
CannotChangePassword
CanonicalName
Certificates
City
CN
codePage
comment
Company
CompoundIdentitySupported
Country
countryCode
Created
createTimeStamp
Deleted
Department
departmentNumber
Description
DisplayName
DistinguishedName
Division
DoesNotRequirePreAuth
dSCorePropagationData
EmailAddress
EmployeeID
EmployeeNumber
employeeType
Enabled
Fax
fimPrefNameDisplay
fimWpoAcctCode
fimWpoAcctCodeName
fimWpoAddlDeptCd
fimwpoBusinessTitle
fimwpoBusinessUnit
fimwpoBusinessUnitDescription
fimWpoCompanyCode
fimWpoEmployeeStatus
fimWpoEmplRCD
fimWpoEmplType
fimWpoHireDate
fimWpoHomeCity
fimWpoJobCode
fimWpoJobFunction
fimWpoLocationNbr
fimWpoManagerLevel
fimWpoMgrEmployeeID
fimWpoMSSUser
fimWpoOriginalHireDate
fimWpoPerOrg
fimWpoPersonalMail
fimWpoPositionName
fimWpoPositionNumber
fimWpoPrefFirstName
fimWpoPrefLastName
fimWpoPrefMIddleName
fimWpoRegTemp
fimWpoRehireDate
fimWpoSState
fimWpoWebClockUser
GivenName
groupPriority
HomeDirectory
HomedirRequired
HomeDrive
HomePage
HomePhone
info
Initials
instanceType
internetEncoding
isDeleted
KerberosEncryptionType
L
LastBadPasswordAttempt
LastKnownParent
lastLogoff
lastLogon
LastLogonDate
lastLogonTimestamp
legacyExchangeDN
LockedOut
lockoutTime
logonCount
LogonWorkstations
mail
mailNickname
Manager
MemberOf
MNSLogonAccount
MobilePhone
Modified
modifyTimeStamp
mS-DS-ConsistencyGuid
msDS-User-Account-Control-Computed
msExchALObjectVersion
msExchPoliciesExcluded
msExchRecipientDisplayType
msExchVersion
msRTCSIP-ArchivingEnabled
msRTCSIP-FederationEnabled
msRTCSIP-InternetAccessEnabled
msRTCSIP-OptionFlags
msRTCSIP-PrimaryHomeServer
msRTCSIP-PrimaryUserAddress
msRTCSIP-UserEnabled
Name
nTSecurityDescriptor
ObjectCategory
ObjectClass
ObjectGUID
objectSid
Office
OfficePhone
Organization
OtherName
PasswordExpired
PasswordLastSet
PasswordNeverExpires
PasswordNotRequired
physicalDeliveryOfficeName
POBox
PostalCode
PrimaryGroup
primaryGroupID
PrincipalsAllowedToDelegateToAccount
ProfilePath
ProtectedFromAccidentalDeletion
proxyAddresses
pwdLastSet
SamAccountName
sAMAccountType
ScriptPath
sDRightsEffective
ServicePrincipalNames
showInAddressBook
SID
SIDHistory
SmartcardLogonRequired
sn
st
State
StreetAddress
Surname
targetAddress
telephoneNumber
Title
TrustedForDelegation
TrustedToAuthForDelegation
UseDESKeyOnly
userAccountControl
userCertificate
UserPrincipalName
uSNChanged
uSNCreated
whenChanged
whenCreated
wWWHomePage

 

tags: MrNetTek

Windows – Joining a Workgroup using WMIC

email me

Using the commands below, I was able to successfully script a join to a workgroup.

wmic.exe /interactive:off ComputerSystem Where “Name=’%computername%’” Call UnJoinDomainOrWorkgroup FUnjoinOptions=0

wmic.exe /interactive:off ComputerSystem Where “Name=’%computername%’” Call JoinDomainOrWorkgroup name=”Azure”

 

tags: MrNetTek