Powershell script to list machines running the out of date e1000 Adapter in Windows so you can update them to VMXnet3 !
loading...
loading...
Powershell script to list machines running the out of date e1000 Adapter in Windows so you can update them to VMXnet3 !
Run Vmware Powercli
Run
Connect-ViServer %name of server%
Run the output of below to a text file
E.g. .\Get-PendingUpdate.ps1 | Output-File file.txt
Function Get-PendingUpdate {
<#
.SYNOPSIS
Retrieves the updates waiting to be installed from WSUS
.DESCRIPTION
Retrieves the updates waiting to be installed from WSUS
.PARAMETER Computer
Computer or computers to find updates for.
.EXAMPLE
Get-PendingUpdates
Description
-----------
Retrieves the updates that are available to install on the local system
.NOTES
Author: Boe Prox
Date Created: 05Mar2011
#>
#Requires -version 2.0
[CmdletBinding(
DefaultParameterSetName = 'computer'
)]
param(
[Parameter(
Mandatory = $False,
ParameterSetName = '',
ValueFromPipeline = $True)]
[string[]]$Computer
)
Begin {
$scriptdir = { Split-Path $MyInvocation.ScriptName –Parent }
Write-Verbose "Location of function is: $(&$scriptdir)"
#Create container for Report
Write-Verbose "Creating report collection"
$report = @()
}
Process {
ForEach ($c in $Computer) {
Write-Verbose "Computer: $($c)"
If (Test-Connection -ComputerName $c -Count 1 -Quiet) {
Try {
#Create Session COM object
Write-Verbose "Creating COM object for WSUS Session"
$updatesession = [activator]::CreateInstance([type]::GetTypeFromProgID("Microsoft.Update.Session",$c))
}
Catch {
Write-Warning "$($Error[0])"
Break
}
#Configure Session COM Object
Write-Verbose "Creating COM object for WSUS update Search"
$updatesearcher = $updatesession.CreateUpdateSearcher()
#Configure Searcher object to look for Updates awaiting installation
Write-Verbose "Searching for WSUS updates on client"
$searchresult = $updatesearcher.Search("IsInstalled=0")
#Verify if Updates need installed
Write-Verbose "Verifing that updates are available to install"
If ($searchresult.Updates.Count -gt 0) {
#Updates are waiting to be installed
Write-Verbose "Found $($searchresult.Updates.Count) update\s!"
#Cache the count to make the For loop run faster
$count = $searchresult.Updates.Count
#Begin iterating through Updates available for installation
Write-Verbose "Iterating through list of updates"
For ($i=0; $i -lt $Count; $i++) {
#Create object holding update
$update = $searchresult.Updates.Item($i)
#Verify that update has been downloaded
If ($update.IsDownLoaded -eq "True") {
$temp = "" | Select Computer, Title, KB,IsDownloaded
$temp.Computer = $c
$temp.Title = ($update.Title -split('\('))[0]
$temp.KB = (($update.title -split('\('))[1] -split('\)'))[0]
$temp.IsDownloaded = "True"
$report += $temp
}
Else {
$temp = "" | Select Computer, Title, KB,IsDownloaded
$temp.Computer = $c
$temp.Title = ($update.Title -split('\('))[0]
$temp.KB = (($update.title -split('\('))[1] -split('\)'))[0]
$temp.IsDownloaded = "False"
$report += $temp
}
}
}
Else {
#Nothing to install at this time
Write-Verbose "No updates to install."
#Create Temp collection for report
$temp = "" | Select Computer, Title, KB,IsDownloaded
$temp.Computer = $c
$temp.Title = "NA"
$temp.KB = "NA"
$temp.IsDownloaded = "NA"
$report += $temp
}
}
Else {
#Nothing to install at this time
Write-Warning "$($c): Offline"
#Create Temp collection for report
$temp = "" | Select Computer, Title, KB,IsDownloaded
$temp.Computer = $c
$temp.Title = "NA"
$temp.KB = "NA"
$temp.IsDownloaded = "NA"
$report += $temp
}
}
}
End {
Write-Output $report
}
}
$GetVM = Get-VM |
Where {$_.Guest -match 'windows'} |
Where {$_.PowerState -eq 'PoweredOn'}
Foreach ($vm in $GetVM)
{
$vm.Name
Get-PendingUpdate -Computer $vm.Guest.IPAddress[0]
}
This will only work once a host has been added to Vcenter.
Use Vmware CLI to run this with the variables in Square Brackets edited out
This will change from Multipath to Round Robin
Connect-VIServer [VCENTER-SERVER-ADDRESS]
$hostview = Get-View -Viewtype HostSystem –filter @{“Name”=”[Fully qualified name of server]”}
$storageSystem = Get-View $hostview.ConfigManager.StorageSystem
$policy = new-object VMware.Vim.HostMultipathInfoLogicalUnitPolicy
#$policy.policy = "VMW_PSP_MRU"
$policy.policy = "VMW_PSP_RR"
$storageSystem.StorageDeviceInfo.MultipathInfo.lun | foreach { $storageSystem.SetMultipathLunPolicy($_.ID, $policy) }
Trying to get the Solarwinds Veeam Backup and Recovery Template working, After installing the powershell plugin via BPS_x64.msi, when trying to run Powershell commands , I could not include to the Veeam VeeamPSSnapIn.
Turns out it hadn’t installed and referenced the .dll properly , below can be saved as .reg files and run , depending where your Veeam.Backup.PowerShell.dll is located
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\VeeamPSSnapIn]
"PowerShellVersion"="2.0"
"Vendor"="Veeam"
"Description"="This is a PowerShell snap-in that includes the Veeam's cmdlet."
"VendorIndirect"="VeeamPSSnapIn, Veeam"
"DescriptionIndirect"="VeeamPSSnapIn,This is a PowerShell snap-in that includes the Veeam's cmdlet."
"Version"="8.0.0.0"
"ApplicationBase"="C:\\Program Files\\Veeam\\Backup and Replication\\Backup"
"AssemblyName"="Veeam.Backup.PowerShell, Version=8.0.0.0, Culture=neutral, PublicKeyToken=bfd684de2276783a"
"ModuleName"="C:\\Program Files\\Veeam\\Backup and Replication\\Backup\\Veeam.Backup.PowerShell.dll"
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\VeeamPSSnapIn]
"PowerShellVersion"="2.0"
"Vendor"="Veeam"
"Description"="This is a PowerShell snap-in that includes the Veeam's cmdlet."
"VendorIndirect"="VeeamPSSnapIn, Veeam"
"DescriptionIndirect"="VeeamPSSnapIn,This is a PowerShell snap-in that includes the Veeam's cmdlet."
"Version"="8.0.0.0"
"ApplicationBase"="C:\\Program Files\\Veeam\\Backup and Replication\"
"AssemblyName"="Veeam.Backup.PowerShell, Version=8.0.0.0, Culture=neutral, PublicKeyToken=bfd684de2276783a"
"ModuleName"="C:\\Program Files\\Veeam\\Backup and Replication\\Veeam.Backup.PowerShell.dll"
New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine -ValueFromExtensionProperty 'Config.tools.ToolsVersion' -Force
New-VIProperty -Name ToolsVersionStatus -ObjectType VirtualMachine -ValueFromExtensionProperty 'Guest.ToolsVersionStatus' -Force
Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus | Export-Csv -NoTypeInformation -UseCulture -Path C:\VMHWandToolsInfo.csv
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic –AllowRedirection
Import-PSSession $Session
We use this great script http://deptive.co.nz/remote-assistance-powershell-gui-for-xenapp/ for remote assistance on a Citrix Farm , however it does not work with 7 out of the box , to get this working with XenApp 7 follow :
Install SDK’s from the MSI’s on the CD (Bust the XenApp 7.x ISO)
1. To import all the cmdlets, type:
Add-PSSnapin Citrix.*.Admin.V*
Modify Script to point to the Data Collector:
http://support.citrix.com/static/kc/CTX127254/help/Get-BrokerSession.html
Add User to the Citrix Administrators in Citrix Studio
Add User to the SG_Remote_Assist_Allow Group (this is a member of the Offer Remote Assist local group on Server)
http://discussions.citrix.com/topic/361303-where-can-i-download-the-xd-sdk-for-75/
To copy
################################## Import ActiveDirectory ##############################################
Import-Module ActiveDirectory
################################## Import Exchange snap-in #############################################
add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
########################################################################################################
#Clear-host
# Gets all of the users info to be copied to the new account
#Checking the user to copy if it exist
do {
$nameds = Read-Host "Copy From Username"
if (dsquery user -samid $nameds){"AD User Found"
}
elseif ($nameds = "null") {"AD User not Found"}
}
while ($nameds -eq "null")
#Checking if the new user exist
do {
$NewUserds = Read-Host "New Username"
While ( $NewUserds -eq "" ) { $NewUserds = Read-Host "New Username"}
$NewUser = $Newuserds
#check if AD user exist
if (dsquery user -samid $NewUserds){"Ad User Exist"}
#check imanage user exist
$SQLServer = "imanagesqlserver" #use Server\Instance for named SQL instances!
$SqlQuery = "SELECT sum(A+B) FROM (select COUNT(1) as A FROM [imanagedatabase].[MHGROUP].DOCUSERS where [USERID]='$NewUserds') a
CROSS JOIN (select COUNT(1) as B FROM [imanagedatabase2].[MHGROUP].DOCUSERS where [USERID]='$NewUserds') b"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server = $SQLServer; Integrated Security = True"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
[void]$SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$UserExist = $DataSet.Tables[0]| select -expand Column1
if ($UserExist -gt 0) {
$NewUserds -eq ""
"iManage User Found"
}
elseif ($NewUserds = "no") {"Validation OK"}
}
while ($Newuserds -ne "no")
# Gets all of the users info to be copied to the new account
$name = Get-AdUser -Identity $nameds -Properties *
$DN = $name.distinguishedName
$OldUser = [ADSI]"LDAP://$DN"
$Parent = $OldUser.Parent
$OU = [ADSI]$Parent
$OUDN = $OU.distinguishedName
$NewUser = Read-Host "New Username"
$firstname = Read-Host "First Name"
$Lastname = Read-Host "Last Name"
$Extention = Read-Host "Users Extension"
$Password = Read-Host "New Password"
$SecurePassword = ConvertTo-SecureString $Password –asplaintext –force
$NewName = "$firstname $lastname"
$domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$newuserfinitial = $firstname.substring(0,1)
$pager = $name.Pager
$newusernumber= $pager.Substring(0,$pager.Length-3)+$Extention
$OldNotes = $name.info
#Remove Spaces for Make Email Alias Correct
$Lastnamens = $Lastname -replace '\s',''
# Creates the user from the copied properties
New-ADUser -SamAccountName $NewUser -Name $NewName -GivenName $firstname -Surname $lastname -EmailAddress $newuserfinitial$Lastnamens@domain.com -Instance $DN -Path "$OUDN" -AccountPassword $SecurePassword –userPrincipalName $NewUser@$domain -Company $name.Company -Department $name.Department -Manager $name.Manager -title $name.Title -Description $name.Description -HomePage $name.HomePage -Office $name.Office -City $name.city -PostalCode $name.postalcode -Country $name.country -OfficePhone $newusernumber -Fax $name.fax -State $name.State -StreetAddress $name.StreetAddress -homedrive "H" -homedirectory "\\domain.local\dfs\home\$NewUser" -Enabled $true
#Copy Signature
Set-ADUser $NewUser -Replace @{info="$OldNotes"}
Set-ADUser $NewUser -Replace @{pager="$newusernumber"}
# Set Profile Location
$NewUserAdDetails = Get-AdUser -Identity $NewUser -Properties *
$DN = $NewUserAdDetails.distinguishedName
$NewUserLdap = [ADSI]"LDAP://$DN"
$NewUserLdap.psbase.invokeset(“terminalservicesprofilepath”,”\\domain.local\dfs\profiles\$NewUser”)
$NewUserLdap.setinfo()
# gets groups from the Copied user and populates the new user in them
write-host "Copying Group Membership"
$groups = (GET-ADUSER –Identity $name –Properties MemberOf).MemberOf
foreach ($group in $groups) {
Add-ADGroupMember -Identity $group -Members $NewUser
}
$count = $groups.count
#Check to see if new user is member of group and do things - Use Windows 2000 Name
$newusergroups = (GET-ADUSER –Identity $NewUser –Properties MemberOf).MemberOf
if ($newusergroups -match '#ADGROUP') {
$currentuser = [Environment]::UserName
#Give the user who is running the script full permissions to the user Mailbox but don't add to Outlook
Add-MailboxPermission -Identity $NewUser -User $currentuser -AccessRights FullAccess -Automapping $false
#Create the Folders
C:\scripts\Folders.ps1 $NewUser
#Remove Permissions
Remove-MailboxPermission -Identity $NewUser -User $currentuser -AccessRights FullAccess
}
# List of Mailbox DB
$databases = Get-MailboxDatabase
$Count = 0
Foreach ($database in $databases){
Write-Host $Count "." $database.Name
$Count ++
}
$Choice = Read-Host "Please choose a Database to list databases from"
$db = $databases[$Choice].Name
# After some testing it seems that sometimes ad don't have time to process everything and while trying to access the user for exchange it gave error.
write-host "Waiting time for Ad to process earliers operations"
Start-Sleep -s 30
#Clear-host
# Creates the New users mailbox
Enable-Mailbox -Identity $NewUser@$domain -alias "$NewUser" -ManagedFolderMailboxPolicyAllowed -Database "$db"
# Sets secondary smtp adress while specifying the Primary smtp adress(1st address with the SMTP is the primary one).
Start-Sleep -s 15
Set-Mailbox "$NewUser" -EmailAddressPolicyEnabled $false -EmailAddresses SMTP:"$newuserfinitial$Lastnamens@domain.com"
#Does the user have a value for custom attribute e.g. Partner? if so copy to new user
if(Get-Mailbox -Identity $user | Select -Expand CustomAttribute1) { Set-Mailbox -Identity $newuser -CustomAttribute1 (Get-Mailbox -Identity $user | Select -Expand CustomAttribute1) }
#clear-host
# Creates the New user Profile Folder
New-item \\domain.local\dfs\profiles\"$newuser" -type directory
$acl = Get-Acl \\domain.local\dfs\profiles\"$NewUser"
$acl.GetAccessRules($true, $true, [System.Security.Principal.NTAccount])
$acl.SetAccessRuleProtection($true, $true)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule "domain\$NewUser","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow"
$acl.addAccessRule($rule)
Set-Acl \\domain.local\dfs\profiles\"$NewUser" $acl
# Creates the New user Home Folder
New-item \\domain.local\dfs\home\"$newuser" -type directory
$acl = Get-Acl \\domain.local\dfs\home\"$NewUser"
$inheritanceFlags = ([Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [Security.AccessControl.InheritanceFlags]::ObjectInherit)
$propagationFlags = [Security.AccessControl.PropagationFlags]::None
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule "domain\$NewUser","FullControl",$inheritanceFlags, $propagationFlags,"Allow"
$acl.addAccessRule($rule)
Set-Acl \\domain.local\dfs\home\"$NewUser" $acl
Set-AdUser -Identity $NewUser -Replace @{HomeDirectory="\\domain.local\dfs\home\$NewUser"}
$homedrivereadded = Read-Host "Now can you reset the homedrive as the script doesn't do a very good job"
#Logging in as user to create redirected
$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo
$Process = New-Object System.Diagnostics.Process
$ProcessInfo.FileName = "$($env:SystemRoot)\system32\cmdkey.exe"
$ProcessInfo.Arguments = "/generic:TERMSRV/TERMINALSERVERNAME /user:$NewUser /pass:$Password"
$Process.StartInfo = $ProcessInfo
$Process.Start()
$ProcessInfo.FileName = "$($env:SystemRoot)\system32\mstsc.exe"
$ProcessInfo.Arguments = "$MstscArguments /v $Computer"
$Process.StartInfo = $ProcessInfo
$Process.Start()
Recently we had a task to update all the Finished folders in Olympus to remove old items old than 2 months. I tried to use the Group function of this software to deploy the settings however they weren’t taking. Instead of editing the individual users I wrote the following powershell to Edit each users XML configuration
$Files = Get-ChildItem \folderlocation
ForEach($file in $files) {
$xml = [pastacode provider="manual" lang="markup" manual=""](Get-Content $file.FullName)
$xml2 = $xml.Profile.TranscriptionInformation.FolderDesign.FolderList.Folder | Where-Object { $_.parent -eq '101' -and $_.type -eq '115'}
$xml2.Actions.Cleaning.fixed = [io.path]::GetFileNameWithoutExtension($file.Name)
$xml2.Actions.Cleaning.Enabled = '1'
$xml2.Actions.Cleaning.Period = '2'
$xml2.Actions.Cleaning.Unit = '1'
$xml2.Actions.Cleaning.Option = '2'
$xml.Save($file.FullName)
}
# Change these values
$Logfile = “C:\Scripts\Logs\AffSql_” + (Get-Date).tostring(“yyyyMMdd”) + “.log”
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -erroraction silentlyContinue
# Copy Folder with Robocopy
$command = 'Robocopy.exe "\\unc\path\" "E:\localpath" /S /MIR /R:10 /W:5 /LOG+:$Logfile /NP /TS /FP /COPY:DAT'
iex $command
# Send E-mail message with log file attachment
$smtpServer = "smtpserver"
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "from@domain.com"
$msg.To.Add("to@domain.com")
$msg.Subject = "SQL Backup"
$msg.Body = get-content $Logfile | out-string
$smtp.Send($msg)