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

Google Chrome – 74.0.3729.131

email me

Download

New Chrome browser is available here:

https://enterprise.google.com/intl/en_version/chrome/chrome-browser/ mirror

 

Size

55.3 MB


MSI Property Table

UpgradeCode                                 {C1DFDF69-5945-32F2-A35E-EE94C99C7CF4}
AllowDowngradeSubstitution      false
ALLUSERS                                        1
ARPPRODUCTICON                        icon.ico
ARPNOMODIFY                              1
Manufacturer                                 Google LLC
ProductCode                                   {15860903-F4E3-3BAA-B5C0-E9E58157EE74}
ProductLanguage                          1033
ProductName                                 Google Chrome
ProductVersion                              67.164.16515
SecureCustomProperties             NEWPRODUCTFOUND;UPGRADEFOUND


Silent Install

setup.msi /quiet /norestart


Notes

Release Notes

 

tags: MrNetTek

PowerShell – Install AppX via Command Line

email me

Command

powershell.exe -noprofile -command “Add-AppxPackage -Path .\setup.appx”

 

Output

 


Notes

Example 1: Add an app package

PS C:\> Add-AppxPackage -Path “C:\Users\GeorgeStark\Desktop\MyApp.appx” -DependencyPath “C:\Users\GeorgeStark\Desktop\winjs.appx”


Example 2: Add a disabled app package in development mode

PS C:\> $ManifestPath = (Get-AppxPackage -Name “*WindowsCalculator*”).InstallLocation + “\Appxmanifest.xml”

PS C:\> Add-AppxPackage -Path $ManifestPath -Register -DisableDevelopmentMode


Example 3: Add an app along with its optional packages

PS C:\> Add-AppxPackage -Path “C:\Users\GeorgeStark\Desktop\MyApp.appxbundle” -ExternalPackages

“C:\Users\user1\Desktop\optionalpackage1.appx”,”C:\Users\GeorgeStark\Desktop\optionalpackage2.appxbundle”

PS C:\> Add-AppxPackage -Path “C:\Users\GeorgeStark\Desktop\MyApp.appxbundle” -OptionalPackages “29270sandstorm.OptionalPackage1_gah1vdar1nn7a”


Example 4: Install only the required section of a streaming app

PS C:\> Add-AppxPackage -Path “C:\Users\GeorgeStark\Desktop\MyApp.appxbundle” -RequiredContentGroupOnly

* hopefully you get my humor with George Stark.

 

tags: MrNetTek