JaapsPowershell.psm1
function Get-JaapModuleCommands { cd 'C:\Users\JaTer\' Remove-Module JaapsPowershell Import-Module .\JaapsPowershell\JaapsPowershell.psm1 (Get-Command -Module JaapsPowershell).Name Update-ModuleManifest .\JaapsPowershell\JaapsPowershell.psd1 -ModuleVersion 1.0.6 -FunctionsToExport @($((Get-Command -Module JaapsPowershell).Name)) Publish-Module -Path .\JaapsPowershell\ -Force -NuGetApiKey "" } function Open-JaapPowershellModule { $ScriptVersion = (Get-Module JaapsPowershell).Version powershell_ise.exe "C:\Program Files\WindowsPowerShell\Modules\JaapsPowershell\$($ScriptVersion)\JaapsPowershell.psm1" } function Get-AmarisPersoneelsNummers { $users =@(); foreach($p in $Personeelsnummers) { $users += Get-ADUser -LDAPFilter "(employeeid=$($p.Personeelsnummer))" -Properties Userprincipalname, samaccountname, displayname, lastlogondate | select Userprincipalname, samaccountname,displayname, lastlogondate, @{N="Groupmemberships";E={Get-ADPrincipalGroupMembership $_}} } ; $users } function Get-JaapCloudOnlyMailbox { Get-Mailbox -ResultSize Unlimited | ? RemoteRecipientType -EQ None | sort WindowsEmailAddress | select WindowsEmailAddress,RemoteRecipientType #foreach($u in (Get-AzureADUser -All $true | Where {$_.DirSyncEnabled -eq $true})) { Get-Mailbox $u.mail | ? RemoteRecipientType -EQ None | select WindowsEmailAddress,RemoteRecipientType } } function Get-JaapAADUserMail { $ADUsers = (Get-AzureADUser -All $true | Where {$_.DirSyncEnabled -eq $true}).mail #Get-Mailbox -ResultSize Unlimited | ? RemoteRecipientType -EQ None | sort WindowsEmailAddress | select WindowsEmailAddress,RemoteRecipientType | foreach { if($_.WindowsEmailAddress -in $ADUsers) { $_ }} } function New-JaapAADUser { Param ( [parameter(mandatory = $true)][string]$UserPrincipalName, [string]$Password ) #$User = "svc_IntuneNDES@amariszorggroep.onmicrosoft.com" New-MsolUser -UserPrincipalName $UserPrincipalName -Password $Password -DisplayName "svc InTune NDES Certificates" -PasswordNeverExpires $true -ForceChangePassword $false Set-MsolUser -UserPrincipalName $User -UsageLocation NL #Set-MsolUserLicense -UserPrincipalName svc_IntuneNDES@amariszorggroep.onmicrosoft.com -AddLicenses "amariszorggroep:EMS" } function Get-Overige_Zooi { #______________________________________________ <# SET backuplogfile=C:\tasks\Backup\log\backup2disk_%date:~9,4%-%date:~6,2%-%date:~3,2%_%time:~0,2%-%time:~3,2%-%time:~6,2%.log robocopy A:\ B:\ /MIR /NDL /NP >> "%backuplogfile%" sleep 5 #> #______________________________________________ #Get all printers: $printserver = "amar-prt01.amaris.local" Get-WMIObject -class Win32_Printer -computer $printserver | ? {$_.Name -eq "PRN069"} | Select Name,DriverName,PortName #______________________________________________ #Gooi alle bestanden en submappen weg #del * /f /s /q /a #for /f "tokens=*" %G in ('dir /b /a:d "."') do rd %G /s /q #Gooi alle files ouder dan x weg forfiles -p "." -s -m *.* -d -31 -c "cmd /c del @path" gci '\\cvx-nas02\usbshare1' -Directory | gci -Include '*.vbk','*.vrb' -Recurse | ? LastWriteTime -lt (Get-Date).AddDays(-14) | Remove-Item gci '.' -recurse | ? {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} | Remove-Item #______________________________________________ #Vind bestanden met extensie langer dan x tekens gci '\\svfsamar01\userdata$' -File -Recurse | where {$_.extension.length -gt 6} | select Fullname #Crypto herstel robocopy "D:\DATA\Amaris\Locaties\Amaris Holding" "\\svfsamar01\Locaties$\Amaris Holding" /XC /XN /XO /E /R:1 /W:1 /NP /NDL /FP #______________________________________________ #Geef iemand rechten op een map icacls "EEN_MAP" /grant DOMAIN\admin_beheer:(OI)(CI)M get-childitem \\svfsamar01\netprog$ -recurse | where{$_.psiscontainer} | get-acl | Format-List takeown /f MAPNAAM /a /r /d Y #______________________________________________ net stop spooler net start spooler #______________________________________________ [DateTime]::FromFileTime((Get-ADUser adm_winvision -Properties Lastlogon).Lastlogon) #______________________________________________ #Geef MemberOf groepen weer van User Get-ADPrincipalGroupMembership "MBakker2" | Select Name | Sort-Object Name Get-ADGroupMember "GG_MB_Apple" | Select Name | Sort-Object Name Get-ADGroupMember "BG_CTX_PortalMFA_Users" -Recursive | Get-ADUser -Properties Mail | Select-Object Name, Mail | ft Get-ADUser -SearchBase "OU=mailboxen,OU=Gebruikersgroepen,DC=amaris,DC=local" -LDAPFilter "(Name=*)" Get-ADUser -SearchBase "OU=Users,OU=Amaris,DC=amaris,DC=local" -LDAPFilter "(Name=*)" #Groeplidmaatschap kopieren naar andere groep Add-ADGroupMember "App_mijnCaress_Medewerkerportaal" -member (Get-ADGroupMember "App_mijnCaress_Zorgdossier" | Select -ExpandProperty SamAccountName) #Rechten kopieren van andere user Get-ADUser -Identity "ngietema" -Properties memberof | Select-Object -ExpandProperty memberof | Add-ADGroupMember -Members "testjaap" -PassThru | Select-Object -Property SamAccountName #Groepen iPad $User = "A00665635" Add-ADGroupMember "App_Azure_MijnCaress" -Member $User Add-ADGroupMember "App_mijnCaress_Medewerkerportaal" -Member $User Add-ADGroupMember "App_Office365" -Member $User Add-ADGroupMember "iPad Users Thuiszorg" -Member $User Add-ADGroupMember "Reporting" -Member $User Remove-ADGroupMember "App_Outlook" -Members $User -Confirm:0 Add-ADGroupMember "Reporting_HVZ" -Member $User Add-ADGroupMember "Amaris_MFA" -Member $User Remove-ADGroupMember "Amaris_MFA" -Members "testo365" -Confirm:0 Remove-ADGroupMember "Amaris Iedereen" -Members "testo365" -Confirm:0 Remove-ADGroupMember "App_Algemeen" -Members "testo365" -Confirm:0 Remove-ADGroupMember "App_Outlook" -Members "testo365" -Confirm:0 #Groepen HVZ $User = "A00665360" Add-ADGroupMember "Amaris_MFA" -Member $User Add-ADGroupMember "Reporting_HVZ" -Member $User #______________________________________________ #Enable-mailbox Amaris $user = "A00039663" Enable-Mailbox $user Get-Mailbox $user | select PrimarySmtpAddress,EmailAddressPolicyEnabled Set-Mailbox $user -EmailAddressPolicyEnabled $false Set-Mailbox $user -PrimarySmtpAddress ((Get-ADUser $user).UserPrincipalName) #______________________________________________ #Full access rights mailbox Add-MailboxPermission -Identity trefpuntdk@amaris.nl -User N.kooij@amaris.nl -AccessRight FullAccess -InheritanceType All #Zoek rechten van 1 persoon: Get-Mailbox -ResultSize 2000 | Get-MailboxPermission -User AMARIS\TVial | fl Identity, User, AccessRights #Verzonden items in shared mailbox en Sendonbehalf: #Exchange 2010: Set-MailboxSentItemsConfiguration t.teamjaap@amaris.nl -SendAsItemsCopiedTo SenderAndFrom -SendOnBehalfOfItemsCopiedTo SenderAndFrom #Office 365: Set-Mailbox mbxICT@amaris.nl -MessageCopyForSentAsEnabled $True -MessageCopyForSendOnBehalfEnabled $True Add-ADPermission -Identity ict@amaris.nl -User t.o365@amaris.nl -AccessRights ExtendedRight -ExtendedRights "send as" Set-Mailbox huismeester.amerhorst@amaris.nl -GrantSendOnBehalfTo huismeester.arkhemheen@amaris.nl #Disable webmail: Set-CASMailbox -Identity "USER" -OWAEnabled $false #Mailbox export: $ArchiveUsername = "kanselarij2" New-MailboxExportRequest -Mailbox $ArchiveUsername -FilePath \\amar-nas02\UserArchive\2018\Mail\$ArchiveUsername.pst Get-MailboxExportRequest | Get-MailboxExportRequestStatistics Get-MailboxExportRequest | where {$_.status -eq "Completed"} | Remove-MailboxExportRequest -confirm:$false #Mailbox Statistics: Get-MailboxFolderStatistics zhambz | where {$_.FolderType -eq "Root"} | fl Identity, ItemsInFolderAndSubfolders, FolderAndSubfolderSize #Office365 Get-Mailbox -ResultSize 5 | Get-MailboxStatistics | select DisplayName, @{name=”TotalItemSize (GB)”;expression={[math]::Round((($_.TotalItemSize.Value.ToString()).Split(“(“)[1].Split(” “)[0].Replace(“,”,””)/1MB),2)}},ItemCount | sort "TotalItemSize (GB)" #Message Tracking Get-MessageTrackingLog -ResultSize Unlimited -Start "5-2-2016 7:00" -End "5-2-2016 23:00" -Recipients leo.melse@nemag.com | select "Timestamp","ClientIp","ClientHostname","ServerIp","ServerHostname","SourceContext","ConnectorId","Source","EventId","InternalMessageId","MessageId",{$_.Recipients},{$_.RecipientStatus},"TotalBytes","RecipientCount","RelatedRecipientAddress","Reference","MessageSubject","Sender","ReturnPath","Directionality","TenantId","OriginalClientIp","MessageInfo","MessageLatency","MessageLatencyType","EventData" | Export-Csv C:\tmp\mail.csv Get-MessageTrace -Start "5-26-2016 1:00" -End "5-26-2016 23:00" -RecipientAddress sebastiaan.danjou@proassist.nl "Timestamp","ClientIp","ClientHostname","ServerIp","ServerHostname","SourceContext","ConnectorId","Source","EventId","InternalMessageId","MessageId",{$_.Recipients},{$_.RecipientStatus},"TotalBytes","RecipientCount","RelatedRecipientAddress","Reference","MessageSubject","Sender","ReturnPath","Directionality","TenantId","OriginalClientIp","MessageInfo","MessageLatency","MessageLatencyType","EventData" Get-MailboxDatabase -Status | sort name | select name,@{N='DB Size (Gb)';E={$_.DatabaseSize.ToGb()}},@{N='Available New Mbx Space (Gb)';E={$_.AvailableNewMailboxSpace.ToGb()}} Get-MailboxDatabase -Status | sort name | select name,@{N='DB Size';E={$_.DatabaseSize}},@{N='Available New Mbx Space';E={$_.AvailableNewMailboxSpace}} Set-ADUser paulie -Replace @{msExchHideFromAddressLists=$true} Get-PublicFolder -Recurse -Identity "\" | ? {$_.Foldertype -eq "IPF.Appointment"} | Add-PublicFolderClientPermission -AccessRights PublishingEditor -User "amaris.local/Amaris/Users/Standard users/Gietema, Nel" #______________________________________________ #Mailbox recovery: Search-Mailbox $user -TargetMailbox "t.o365@amaris.nl" -TargetFolder PVellekoop -LogLevel Full #______________________________________________ #User archiveren: <# set ArchiveUsername=adikkeboom robocopy \\SVFSAMAR01\UserData$\%ArchiveUsername% \\amar-nas02\UserArchive\2017\Home\%ArchiveUsername% /MIR /W:1 /R:1 robocopy \\amar-sdb08\profiles$\%ArchiveUsername%.AMARIS.V2 \\spbuamar01\_oldusers\2017\Home\%ArchiveUsername%.AMARIS.V2 /MIR /W:1 /R:1 #> $User = "" Get-Mailbox $User | Disable-Mailbox -Confirm:$false Get-ADUser $User | Move-ADObject -TargetPath "OU=Disabled Users,OU=Users,OU=Amaris,DC=Amaris,DC=local" #______________________________________________ #Exchange Powershell connectie $MsExchSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://amar-sm01.amaris.local/Powershell/ -Authentication Kerberos Import-PSSession $MsExchSession #______________________________________________ #Office 365 Powershell connectie #Verbinden: $UserCredential = Get-Credential -UserName admin_beheer@amariszorggroep.onmicrosoft.com -Message "Enter password" $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session #Verbreken: Get-PSSession | Remove-PSSession #______________________________________________ #Powershell Azure connectie Connect-AzureRmAccount Get-AzureRmSubscription Select-AzureRmSubscription -SubscriptionId #______________________________________________ #Office365 ADSync handmatig starten Start-ADSyncSyncCycle -PolicyType Delta #______________________________________________ Get-SmbOpenFile | select ClientUserName,Path | sort ClientUserName #______________________________________________ #IP Powershell Get-NetIPConfiguration Clear-DnsClientCache Resolve-DnsName Test-NetConnection Test-Connection #______________________________________________ #Windows tijd w32tm /config /update /manualpeerlist:nl.pool.ntp.org /syncfromflags:manual /reliable:yes w32tm /query /source net time /querysntp w32tm /stripchart /computer:TIJDSERVER /samples:1 /dataonly w32tm /resync #______________________________________________ #Telnet mail <# telnet mail.domein.nl 25 mail from: verzender@domein.nl rcpt to: ontvanger@domein.nl data subject: Test 01 . #> #______________________________________________ #Geïnstalleerde programma's Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | export-csv c:\installedprograms1.txt Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | export-csv c:\installedprograms2.txt #______________________________________________ #Citrix XenApp Verwijder "Unknown worker group" uit Appcenter: dscheck /clean #______________________________________________ #VMware update via internet <# esxcli network firewall ruleset set -e true -r httpClient esxcli software sources profile list -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml | grep ESXi-6.0.0-2016 esxcli software profile update -p ESXi-6.0.0-20170304001-standard -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml esxcli network firewall ruleset set -e false -r httpClient VMware unmap esxcli storage vmfs unmap -l amar-san01:store01 -n 8000 esxcli storage vmfs unmap -l amar-san01:store02 -n 8000 esxcli storage vmfs unmap -l amar-san01:store03 -n 8000 esxcli storage vmfs unmap -l amar-san01:store04 -n 8000 esxcli storage vmfs unmap -l amar-san01:store05 -n 8000 esxcli storage vmfs unmap -l amar-san01:store07 -n 8000 esxcli storage vmfs unmap --volume-label=amar-san01:store01 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=amar-san01:store02 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=amar-san01:store03 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=amar-san01:store04 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=amar-san01:store05 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=amar-san01:store07 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=amar-san01:store08 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=amar-san01:storeISO --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=vmfs31 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=vmfs32 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=vmfs33 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=vmfs34 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=vmfs35 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=vmfs36 --reclaim-unit=6400 esxcli storage vmfs unmap --volume-label=vmfsISO --reclaim-unit=6400 #> #______________________________________________ #Autologon <# REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /d 1 /t REG_SZ /f REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /d "User" /t REG_SZ /f REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /d "User" /t REG_SZ /f REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /d "." /t REG_SZ /f #> #______________________________________________ #Mailbox move to Office365 $ONPREMCREDS = Get-Credential -UserName AMARIS\admin_beheer -Message "Enter password" New-MoveRequest -Identity "r.boer3@amaris.nl" -Remote -RemoteHostName webmail.amaris.nl -TargetDeliveryDomain amariszorggroep.mail.onmicrosoft.com -RemoteCredential $ONPREMCREDS -BadItemLimit 0 Get-MoveRequest | Get-MoveRequestStatistics #______________________________________________ Get-MsolAccountSku Set-MsolUser -UserPrincipalName "r.boer3@amaris.nl" -UsageLocation NL Set-MsolUserLicense -UserPrincipalName "r.boer3@amaris.nl" -AddLicenses "amariszorggroep:STANDARDPACK" Set-MsolUserLicense -UserPrincipalName "r.boer3@amaris.nl" -AddLicenses "amariszorggroep:EMS" #______________________________________________ #Get Azure AD roles foreach($Role in (Get-MsolRole)) { Get-MsolRoleMember -RoleObjectId $Role.ObjectId | foreach { $Role.Name + ";"+ $_.DisplayName +";"+ $_.Emailaddress}} #______________________________________________ #Controle dubbele mailbox #On-prem: Get-Mailbox -ResultSize unlimited | select PrimarySmtpAddress | Export-Csv D:\Temp\onprem_mail.csv -NoTypeInformation #Office365: $onprem_mail = Import-Csv D:\Temp\onprem_mail.csv Write-Host "`n`n`n______`n"; foreach($office365_mail in (Get-Mailbox -ResultSize unlimited | select PrimarySmtpAddress)) { if($onprem_mail.PrimarySmtpAddress -contains $office365_mail.PrimarySmtpAddress) { Write-Host $office365_mail.PrimarySmtpAddress} }; Write-Host "`n`n`n______`n"; #Fixen Dubbele mailbox Get-MsolUser -userprincipalname $user -ReturnDeletedUsers | fl UserPrincipalName,ObjectID Remove-MsolUser -ObjectID f65b0440-3aae-40f0-9196-bbd21e99f547 -RemoveFromRecycleBin -Force #______________________________________________ Import-Module activedirectory Import-Module servermanager Add-WindowsFeature SNMP-Service Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 #______________________________________________ #3PAR CLI setclienv showsysobjs 1 => toont ook dedup store showvv -s => Toont gebruikte ruimte en dedup values showvv -r => Toont raw space showspace -cpg SSD_r5 => Gebruikte ruimte op hele RAID #______________________________________________ #VMware cd\ Import-Module VMware.PowerCLI Connect-VIServer localhost Connect-VIServer amar-vc01 Get-VM | sort Name | FT Name, @{Label="ISO file"; Expression = { ($_ | Get-CDDrive).ISOPath }} -AutoSize $NumCpu = 0; foreach($vm in (Get-Cluster Cluster01 | Get-VM | ? {$_.PowerState -eq "PoweredOn"})) {$NumCpu += $vm.NumCpu }; $NumCpu $NumRAM = 0; foreach($vm in (Get-Cluster Cluster01 | Get-VM | ? {$_.PowerState -eq "PoweredOn"})) {$NumRAM += $vm.MemoryGB }; $NumRAM Write-Host "`n`n`n______`n"; foreach($vmh in (Get-VMHost | sort name)) { Write-Host $vmh.name "`n" $NumCpu = 0; foreach($vm in (Get-VMHost $vmh | Get-VM | ? {$_.PowerState -eq "PoweredOn"})) {$NumCpu += $vm.NumCpu }; Write-Host "CPU:" $NumCpu $NumRAM = 0; foreach($vm in (Get-VMHost $vmh | Get-VM | ? {$_.PowerState -eq "PoweredOn"})) {$NumRAM += $vm.MemoryGB }; Write-Host "RAM:" $NumRAM Write-Host "______`n" }; Write-Host "`n`n`n"; Get-VM | Select Name, @{N="Cluster";E={Get-Cluster -VM $_}},@{N="ESX Host";E={Get-VMHost -VM $_}},@{N="Datastore";E={Get-Datastore -VM $_}} | sort Name | ft -Autosize Get-VM | ? {$_.Name -like "AMAR-SRD*"} | sort Name | Select Name, NumCPU, MemoryGB Get-Cluster Cluster01 | Get-VM | sort Name | Select Name, NumCPU, MemoryGB, @{N="UsedSpaceGB";E={[math]::Round($_.UsedSpaceGB)}},notes | Export-Csv D:\Temp\VMs_amaris.csv -Delimiter "`t" -NoTypeInformation #______________________________________________ #Windows passwords: rundll32.exe keymgr.dll, KRShowKeyMgr #______________________________________________ Get-Service RESWAS | Set-Service -StartupType Automatic Get-Service RESWAS | Start-Service Get-Service wuauserv | Set-Service -StartupType Automatic Get-Service wuauserv | Start-Service #______________________________________________ Send-MailMessage -From testuseravantage@amaris.nl -To p.vellekoop@amaris.nl -Subject "Test 01" -Body "Test 01" -SmtpServer webmail.amaris.nl #______________________________________________ $password = convertto-securestring -String "password" -AsPlainText -Force read-host -assecurestring | convertfrom-securestring | out-file "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\vmware\amar-vc01_cred.txt" $password = get-content "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\vmware\amar-vc01_cred.txt" | convertto-securestring $credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist "myusername",$password #______________________________________________ $ip = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip; $ip Resolve-DnsName myip.opendns.com -Server resolver1.opendns.com #______________________________________________ #Multiple Terminal server sessions per user REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fSingleSessionPerUser /t REG_DWORD /d 0 /f REG ADD "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarGlomLevel /t REG_DWORD /d 2 /f REG ADD "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" /v EnableAutoTray /t REG_DWORD /d 0 /f Set-ExecutionPolicy RemoteSigned -Force New-Item (Split-Path $PROFILE) -Type Directory -erroraction 0 New-Item $PROFILE -Type file -Value "cd\" -erroraction 0 cd\ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) ## Of: Install-Module chocolatey Install-ChocolateySoftware # choco feature enable -n allowGlobalConfirmation # Chocolatey profile $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" if (Test-Path($ChocolateyProfile)) { Import-Module "$ChocolateyProfile" } #### choco install treesizefree choco install powershell #### Install-PackageProvider -Name NuGet -Force Set-PSRepository -Name PSGallery -InstallationPolicy Trusted #Find-Module PSReadline Find-Module PSReadline | Install-Module #Find-Module VMware.PowerCLI Find-Module VMware.PowerCLI | Install-Module #Find-Module MSOnline Find-Module MSOnline | Install-Module #Find-Module AzureAD Find-Module AzureAD | Install-Module #Find-Module AzureRM Find-Module AzureRM | Install-Module #______________________________________________ $result = @() $vms = Get-view -ViewType VirtualMachine foreach ($vm in $vms) { $obj = new-object psobject $obj | Add-Member -MemberType NoteProperty -Name name -Value $vm.Name $obj | Add-Member -MemberType NoteProperty -Name CPUSocket -Value $vm.config.hardware.NumCPU $obj | Add-Member -MemberType NoteProperty -Name Corepersocket -Value $vm.config.hardware.NumCoresPerSocket $result += $obj } $result #______________________________________________ #ICA bestandsassociatie > CDViewer.exe #______________________________________________ shell:::{80F3F1D5-FECA-45F3-BC32-752C152E456E} #______________________________________________ $users =@(); foreach($p in $Personeelsnummers) { $users += Get-ADUser -LDAPFilter "(employeeid=$($p.Personeelsnummer))" -Properties Userprincipalname, samaccountname, displayname, lastlogondate | select Userprincipalname, samaccountname,displayname, lastlogondate, @{N="Groupmemberships";E={Get-ADPrincipalGroupMembership $_}} } ; $users #______________________________________________ } |