├── Python └── Convert XLSM to XLSX.py ├── ADSync.ps1 ├── Sync-ADSync.ps1 ├── .gitignore ├── powershell.ico ├── Restore-SharepointFiles_V5.bat ├── Archive ├── Restore-SharepointFiles_V5.bat ├── Restore-SharepointFiles_Turner.ps1 ├── Restore-SharepointFiles_Turner_V4.ps1 └── Restore-sharepointFiles_Turner_Simplified.ps1 ├── Get-ProductKey.ps1 ├── LetsHopeThisWorks.ps1 ├── Manage Email Address.ps1 ├── Restore-SharepointFiles_V6.zip ├── Report-ActivesyncReport3.ps1 ├── Report-User_in_Groups-Sharepoint.ps1 ├── README.md ├── SAP_and_Macro_Fix_Rev4 └── Click to Run.lnk ├── Development ├── Percent-Change │ └── Percent-Change │ │ ├── Percent-Change │ │ ├── obj │ │ │ ├── Debug │ │ │ │ ├── Percent-Change.csproj.CoreCompileInputs.cache │ │ │ │ ├── Percent-Change.csprojAssemblyReference.cache │ │ │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ │ │ │ ├── Percent-Change.csproj.AssemblyReference.cache │ │ │ │ ├── .NETFramework,Version=v4.7.2.AssemblyAttributes.cs │ │ │ │ └── App.g.i.cs │ │ │ └── Release │ │ │ │ ├── Percent-Change.csproj.AssemblyReference.cache │ │ │ │ ├── .NETFramework,Version=v4.7.2.AssemblyAttributes.cs │ │ │ │ └── App.g.cs │ │ ├── App.config │ │ ├── Properties │ │ │ ├── Settings.settings │ │ │ ├── Settings.Designer.cs │ │ │ ├── AssemblyInfo.cs │ │ │ └── Resources.Designer.cs │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── MainWindow.xaml.cs │ │ └── MainWindow.xaml │ │ └── Percent-Change.sln ├── Remove-UserFromDistroIfDisabled.ps1 ├── Fileshare Maintenance.ps1 ├── Remove-Orphanedpermissions.ps1 ├── IntuneTaskbarPins.xml ├── IntuneTaskbarPins2.xml ├── TestDirectoryCreation.ps1 ├── Parameter test.ps1 ├── Fileshare Renamer_v2.ps1 ├── Fileshare Renamer(Permission pull)_v3.ps1 └── Fileshare-Rename-Test.ps1 ├── Report-Get-MailboxStatistics.ps1 ├── CopyRunRejoinDomain.bat ├── HowTo-ConvertTimeToString.ps1 ├── Remove-DistributionGroupMember.ps1 ├── ipconfigserver.ps1 ├── wmicbiosserial.ps1 ├── WindowsPowerShell └── Modules │ └── PackageManagement │ └── 1.4.7 │ └── PSGetModuleInfo.xml ├── Report-Export_All_Users_SpecificOU.ps1 ├── Change-Msol-Password.ps1 ├── Get-UserLicenses-CSV.ps1 ├── Batch Ram collection (In Progress).ps1 ├── Delete-Msoluser.ps1 ├── Delete_Msoluser.ps1 ├── Report-Get-UserLicenses-CSV.ps1 ├── CopyElevateRename.bat ├── Change-SPuserEmailAddresses.ps1 ├── Report-LTServiceTagAssignment2.ps1 ├── Intune ├── Intune-ExecutionPolicyCheck.ps1 ├── Intune-ExecutionPolicyRemediation.ps1 ├── Intune-TestDocRemediaton-Creation.ps1 ├── Intune-TestDocRemediaton.ps1 ├── Intune-EnableAutomaticTimeZone.ps1 ├── Intune-EnableAutomaticTimeZone-Logging.ps1 └── Intune-WindowsHelloRemediationCheck.ps1 ├── Report-LTServiceTagAssignment.ps1 ├── NTFSAccess.ps1 ├── Report-Employee_Search_report.ps1 ├── Search-DistributionGroupMembership.ps1 ├── Update User Profiles O365.ps1 ├── Report-Search-DistributionGroupMembership.ps1 ├── Change-Update User Profiles O365.ps1 ├── Rename-PC.ps1 ├── Export-MemberOf.ps1 ├── Update-ADUserDisplayName.ps1 ├── Intune-IPV6-Disable.ps1 ├── Add-UsertoMultipleDistGroups.ps1 ├── AddUsertoMultipleDistGroups.ps1 ├── Compress-printerarchive.ps1 ├── Report-ActivesyncReport2.ps1 ├── SGDList.ps1 ├── Report-Get-AdGroupMembers.ps1 ├── TestUserPasswordREset.ps1 ├── extract-filetobase64.ps1 ├── Report-FilesharePermissions_New.ps1 ├── FindNextAvailableLoop.ps1 ├── BulkCreate-Users.ps1 ├── Add-DistributionGroupMember.ps1 ├── Create-BulkCreate-Users.ps1 ├── Report-AccountSKU_List.ps1 ├── User Access Report.ps1 ├── Report-User Access Report.ps1 ├── Try-Catch-Final_Test.ps1 ├── BulkAdd-DistMembers.ps1 ├── Add-BulkAdd-DistMembers.ps1 ├── Change-ForceChangePassword_False.ps1 ├── RemoveUserDist.ps1 ├── Remove-DistributionGroupMemberfromAll.ps1 ├── Remove-UserDist.ps1 ├── Self-Elevate.ps1 ├── Change-BulkPW_Reset.ps1 ├── Test-ValidateScript.ps1 ├── TestCheck.ps1 ├── Set-UserAccess.ps1 ├── Template-DetectionScriptIntune.ps1 ├── Remove-ADGroupMembers-ConvertDisplaynamesFirst.ps1 ├── Elevate-Session_runAs.ps1 ├── Export-ADGROUPMEMBERS_2022.ps1 ├── Function_Get-LoggedOnUser-ValidateScript.ps1 ├── Change-User Login Status(Block-Allow).ps1 ├── Create-LocalUser Accounts CSV.ps1 ├── Change-MailboxCopyAndForward.ps1 ├── Move-IconsToNewPC.ps1 ├── TestPS1.ps1 ├── Create-LocalUser_Accounts_CSV.ps1 ├── Report-ADGROUPMEMBERS.ps1 ├── Sharepoint_Email_Import.ps1 ├── Install-SOMPrinters.vbs ├── Report-Get-ADusers-MultipleOUs.ps1 ├── Open-RemoteExplorers.ps1 ├── Report-Group_and_users.ps1 ├── Shell-ChooseDirectoryExport.ps1 ├── Template-Foldercreations-Turner.ps1 ├── Report-Get-ADGroup - Excelsior Roles.ps1 ├── ChoicesTest.ps1 ├── Shell-DialogBox.ps1 ├── DistributionGroupMembership.ps1 ├── Report-DistributionGroupMembership.ps1 ├── Install-SharepointPnPModule.ps1 ├── Report-Asset_To_User_1.ps1 ├── Report-Get-ADGroup - Excelsior Fileshare Groups.ps1 ├── Add-FullAccess.ps1 ├── Report-GetAduserInformationSpecific.ps1 ├── Bulk License Change.ps1 ├── Export-ADGROUPMEMBERS.ps1 ├── Test-Menu.ps1 ├── Create-DistGroup.ps1 ├── BulkAdd-DistGroup.ps1 ├── Add-BulkAdd-DistGroup.ps1 ├── Copy-Sharepoint-DocumentLibrary2.ps1 ├── Convert-UserDisplayNamesToSamAccount.ps1 ├── Disable-EmailForwardingO365.ps1 ├── Set-ACLAccess.ps1 ├── AD-TrustRelationshipFix.ps1 ├── Change-Bulk License Change.ps1 ├── Remove-MsoluserLicenses.ps1 ├── Move-SBUsers.ps1 ├── Update-ADComputer_Description.ps1 ├── Copy-Shortcut_To_PubDT_2.ps1 ├── Rename-BulkPhotos.ps1 ├── Replace-ComputerDescription.ps1 ├── Remove-BulkO365Licensing.ps1 ├── Change-ActiveSyncEnabled Script.ps1 ├── Create-DistGroupandMember.ps1 ├── HowTo-AddSubvariables.ps1 ├── Report-Asset_To_User_4.ps1 ├── Report-ADGroupMembers_2019.ps1 ├── Report-Asset_To_User_2.ps1 ├── Get-RemoteServicetag.ps1 ├── Delete-ADComputer.ps1 ├── Remove-Licenses-CSV.ps1 ├── pythongui.py ├── Report-Asset_To_User_v5.ps1 ├── Report-MDMEnrollmentV2.ps1 ├── Report-Asset_To_User_3.ps1 ├── Template_form.ps1 ├── Update-ADUserTitle.ps1 ├── testform.ps1 ├── Report-ProductKey.ps1 ├── Copy-Shortcut_To_PubDT.ps1 ├── Set-ADUserAddressByOU.ps1 ├── TurnerGUIWPF.ps1 ├── Create-MsoluserFull.ps1 ├── Disable-IPv6_All_Adapters_GUI_Source.ps1 ├── Rename-PC_v2.6-Array.ps1 ├── PowerShell Learning Script.ps1 ├── Report-Hostname_OS.ps1 ├── Report-MDMEnrollment.ps1 ├── Report-GetNetworkAdapterConfig.ps1 ├── Rename-PC_v2.ps1 ├── Get-RemoteServicetag_CSV.ps1 ├── Restore-DeletedADObject.ps1 ├── NTFSAccesss_Pit.ps1 ├── CopyAdd-WifiProfile_Manual.ps1 ├── Rename-PC_v2.5.ps1 ├── Get_GPS_Without_Admin.ps1 ├── Disable-Bluebeam_Updates.ps1 ├── Disable-Bluebeam_Updates_GUI.ps1 ├── Update-BatchFiles.ps1 ├── .gitattributes ├── Disable-CredentialGuard.ps1 ├── Disable-AdapterWarningDell.ps1 ├── Printer batch files update.ps1 ├── Disable-IPv6_All_Adapters.ps1 ├── Report-MFAEnrollment.ps1 ├── IPv6_Switch-All_Adapters.ps1 ├── Report-IntuneStaleDeviceID_v3-Parallel.ps1 ├── CopyAdd-WifiProfile.ps1 ├── Report-FilesharePermissions.ps1 └── Report-ExpiringADPasswords-14Days.ps1 /Python/Convert XLSM to XLSX.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ADSync.ps1: -------------------------------------------------------------------------------- 1 | Import-Module Dirsync 2 | Start-OnlineCoexistenceSync -------------------------------------------------------------------------------- /Sync-ADSync.ps1: -------------------------------------------------------------------------------- 1 | Import-Module Dirsync 2 | Start-OnlineCoexistenceSync -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.chm 3 | *.txt 4 | *.vs* 5 | .vs/slnx.sqlite 6 | *.sqlite 7 | 8 | -------------------------------------------------------------------------------- /powershell.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/powershell.ico -------------------------------------------------------------------------------- /Restore-SharepointFiles_V5.bat: -------------------------------------------------------------------------------- 1 | powershell -ep Bypass -File .\Restore-SharepointFiles_V5.ps1 2 | -------------------------------------------------------------------------------- /Archive/Restore-SharepointFiles_V5.bat: -------------------------------------------------------------------------------- 1 | powershell -ep Bypass -File .\Restore-SharepointFiles_V5.ps1 2 | -------------------------------------------------------------------------------- /Get-ProductKey.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/Get-ProductKey.ps1 -------------------------------------------------------------------------------- /LetsHopeThisWorks.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/LetsHopeThisWorks.ps1 -------------------------------------------------------------------------------- /Manage Email Address.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/Manage Email Address.ps1 -------------------------------------------------------------------------------- /Restore-SharepointFiles_V6.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/Restore-SharepointFiles_V6.zip -------------------------------------------------------------------------------- /Report-ActivesyncReport3.ps1: -------------------------------------------------------------------------------- 1 | Get-Mailbox -ResultSize Unlimited | ForEach {Get-MailboxDeviceStatistics -Mailbox $mailbox.samaccountname} -------------------------------------------------------------------------------- /Report-User_in_Groups-Sharepoint.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/Report-User_in_Groups-Sharepoint.ps1 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Powershell-Repository 2 | Repo for my scripts that I've made for work done, not all are functional, some are abandoned or WIP. 3 | -------------------------------------------------------------------------------- /SAP_and_Macro_Fix_Rev4/Click to Run.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/SAP_and_Macro_Fix_Rev4/Click to Run.lnk -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/obj/Debug/Percent-Change.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 2b7cb5d95dd52d737c645a50e9c0f5d06af83d63 2 | -------------------------------------------------------------------------------- /Report-Get-MailboxStatistics.ps1: -------------------------------------------------------------------------------- 1 | Get-CASMailbox | ForEach-Object {Get-MailboxStatistics -Identity $_.Identity | Select * } | Export-CSV C:\CSV\MBStats1FUll.CSv -------------------------------------------------------------------------------- /CopyRunRejoinDomain.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | xcopy .\rejoindomain.ps1 C:\Temp\ 4 | 5 | Powershell.exe -executionpolicy remotesigned -file C:\Temp\rejoindomain.ps1 6 | pause -------------------------------------------------------------------------------- /HowTo-ConvertTimeToString.ps1: -------------------------------------------------------------------------------- 1 | #How to convert current date and time for naming a text file 2 | 3 | Export-csv C:\CSV\FileName-$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv" -------------------------------------------------------------------------------- /Remove-DistributionGroupMember.ps1: -------------------------------------------------------------------------------- 1 | $member = Read-Host "Enter a User" 2 | $Group = Read-Host "Enter a Group Title" 3 | 4 | Remove-DistributionGroupMember -Identity "$Group" -Member $Member -------------------------------------------------------------------------------- /ipconfigserver.ps1: -------------------------------------------------------------------------------- 1 | $Server = Import-csv C:\csv\Srv.csv 2 | 3 | ForEach ($Srvs in $server){ 4 | 5 | Psexec64.exe \\$($Srvs.hostnames) powershell.exe /c ipconfig /all 6 | pause 7 | 8 | } -------------------------------------------------------------------------------- /wmicbiosserial.ps1: -------------------------------------------------------------------------------- 1 | $Node = Import-csv C:\CSV\Test.csv 2 | 3 | ForEach ($Nodes in $Node) { 4 | 5 | Get-CimInstance -Classname Win32_Bios -ComputerName $Nodes | FL SerialNumber 6 | 7 | } -------------------------------------------------------------------------------- /WindowsPowerShell/Modules/PackageManagement/1.4.7/PSGetModuleInfo.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/WindowsPowerShell/Modules/PackageManagement/1.4.7/PSGetModuleInfo.xml -------------------------------------------------------------------------------- /Report-Export_All_Users_SpecificOU.ps1: -------------------------------------------------------------------------------- 1 | Get-Aduser -filter * -SearchBase "OU=Users,OU=US_Excelsior_Medical_Neptune_NJ,OU=Users_And_Computers,DC=excelsior,DC=local" -Properties * | Export-CSV C:\CSV\SomeCSV.CSV -------------------------------------------------------------------------------- /Change-Msol-Password.ps1: -------------------------------------------------------------------------------- 1 | $User = Read-Host "User Email Address:" 2 | $Password = Read-Host "Enter New Password" 3 | 4 | Set-Msoluserpassword -UserPrincipalName $User -NewPassword $Password -ForceChangePassword $False -------------------------------------------------------------------------------- /Get-UserLicenses-CSV.ps1: -------------------------------------------------------------------------------- 1 | Get-msoluser -all | where {$_.isLicensed -eq "true" } | select-object -property DisplayName, userprincipalname, @{name="licenses";expression={$_.licenses.accountskuid}} | Export-CSV "C:\Users and Licenses.csv" -------------------------------------------------------------------------------- /Batch Ram collection (In Progress).ps1: -------------------------------------------------------------------------------- 1 | $Comp = Import-csv 'C:\CSV\Bomgar Export.csv' 2 | 3 | ForEach ($Computer in $Comp) { 4 | 5 | C:\Powershell\ram.ps1 -Computername $Computer.Name | Export-csv C:\CSV\BomgarRam.csv 6 | 7 | } -------------------------------------------------------------------------------- /Delete-Msoluser.ps1: -------------------------------------------------------------------------------- 1 | 2 | do { 3 | 4 | $User = Read-Host "User Email Address:" 5 | 6 | Remove-Msoluser -UserPrincipalName $user -force 7 | 8 | $response = Read-Host "Repeat? (Y/N):" 9 | } 10 | 11 | while ($response -eq "y") -------------------------------------------------------------------------------- /Delete_Msoluser.ps1: -------------------------------------------------------------------------------- 1 | 2 | do { 3 | 4 | $User = Read-Host "User Email Address:" 5 | 6 | Remove-Msoluser -UserPrincipalName $user -force 7 | 8 | $response = Read-Host "Repeat? (Y/N):" 9 | } 10 | 11 | while ($response -eq "y") -------------------------------------------------------------------------------- /Report-Get-UserLicenses-CSV.ps1: -------------------------------------------------------------------------------- 1 | Get-msoluser -all | where {$_.isLicensed -eq "true" } | select-object -property DisplayName, userprincipalname, @{name="licenses";expression={$_.licenses.accountskuid}} | Export-CSV "C:\CSV\Users and Licenses1.csv" -------------------------------------------------------------------------------- /CopyElevateRename.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM Copying Files to C:\Temp 3 | xcopy .\Rename-PC.PS1 /y 4 | 5 | REM Opening Powershell to run Reg Key as Admin 6 | powershell.exe Start-process powershell -verb runas -argumentlist "C:\temp\Rename-PC.PS1" 7 | 8 | -------------------------------------------------------------------------------- /Change-SPuserEmailAddresses.ps1: -------------------------------------------------------------------------------- 1 | $Users = Import-csv "C:\CSV\Medline Email Matches.csv" 2 | 3 | Pause 4 | 5 | Foreach($User in $Users) { 6 | 7 | Set-SPuser -Identity $_.Identity -Email $_.Email -Web Http://Intranet 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Report-LTServiceTagAssignment2.ps1: -------------------------------------------------------------------------------- 1 | $Computers = Import-csv C:\Temp\STLookup.csv 2 | 3 | Foreach($Computer in $Computers){ 4 | 5 | Get-ADcomputer -filter 'Description -like "*$($Computer.servicetags)*"' -properties Description | Select Name, Description 6 | } -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Intune/Intune-ExecutionPolicyCheck.ps1: -------------------------------------------------------------------------------- 1 | #Check Execution policy 2 | $ExecutionPolicyCheck = Get-ExecutionPolicy 3 | 4 | if ($ExecutionPolicyCheck -ne "Bypass") { 5 | #Remediation Needed 6 | Exit 1 7 | }else{ 8 | #No Remediation Needed 9 | Exit 0 10 | } -------------------------------------------------------------------------------- /Report-LTServiceTagAssignment.ps1: -------------------------------------------------------------------------------- 1 | $Computers = Import-csv C:\Temp\STLookup.csv 2 | 3 | Foreach($Computer in $Computers){ 4 | 5 | Get-ADcomputer -filter * -properties Description | Select Name, Description | where {$_.Description -like "*$($Computer.ServiceTags)*"} 6 | } -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/obj/Debug/Percent-Change.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/Development/Percent-Change/Percent-Change/Percent-Change/obj/Debug/Percent-Change.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/Development/Percent-Change/Percent-Change/Percent-Change/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/obj/Debug/Percent-Change.csproj.AssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/Development/Percent-Change/Percent-Change/Percent-Change/obj/Debug/Percent-Change.csproj.AssemblyReference.cache -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/obj/Release/Percent-Change.csproj.AssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RyanC92/Powershell-Repository/HEAD/Development/Percent-Change/Percent-Change/Percent-Change/obj/Release/Percent-Change.csproj.AssemblyReference.cache -------------------------------------------------------------------------------- /Intune/Intune-ExecutionPolicyRemediation.ps1: -------------------------------------------------------------------------------- 1 | #Set-Execution 2 | Set-ExecutionPolicy Bypass -Scope LocalMachine -Force 3 | 4 | $ExecutionPolicyCheck = Get-ExecutionPolicy 5 | 6 | if($ExecutionPolicyCheck -eq "Bypass") 7 | { 8 | Exit 0 9 | } 10 | else 11 | { 12 | Exit 1 13 | } -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /NTFSAccess.ps1: -------------------------------------------------------------------------------- 1 | import-module ntfssecurity 2 | 3 | #$rh = read-host "Enter Parent Directory" 4 | 5 | #cd $rh 6 | 7 | $name = get-childitem -attributes directory -s 8 | 9 | ForEach($directory in $name) { 10 | 11 | Enable-NFTSAccessInheritance -Path $directory.name 12 | 13 | } -------------------------------------------------------------------------------- /Report-Employee_Search_report.ps1: -------------------------------------------------------------------------------- 1 | Get-Aduser -filter * -SearchBase "OU=TMS Users,OU=HQ,DC=excelsior,DC=local" -Properties Name, employeeID, SamAccountName, UserPrincipalName, DistinguishedName | Select Name, employeeID, SamAccountName, UserPrincipalName, DistinguishedName #| Export-csv C:\CSV\TMS-Users.csv -------------------------------------------------------------------------------- /Search-DistributionGroupMembership.ps1: -------------------------------------------------------------------------------- 1 | $identity = get-mailbox -Identity $args[0] 2 | $groups = Get-DistributionGroup 3 | foreach( $group in $groups) 4 | { 5 | if ((Get-DistributionGroupMember $group.identity | select -Expand distinguishedname) -contains $identity.distinguishedname){$group.name} 6 | } -------------------------------------------------------------------------------- /Update User Profiles O365.ps1: -------------------------------------------------------------------------------- 1 | $UpdateCSV | ForEach {Set-MsolUser -UserPrincipalName $_.EMAIL_ADDRESS -FirstName $_.First_Name -LastName $_.Last_Name -Title $_.Title -Office $_.Office -PhoneNumber $_.Office_Phone -StreetAddress $_.Street_address -City $_.City -State $_.State -PostalCode $_.ZIP -Country $_.Country} -------------------------------------------------------------------------------- /Report-Search-DistributionGroupMembership.ps1: -------------------------------------------------------------------------------- 1 | $identity = get-mailbox -Identity $args[0] 2 | $groups = Get-DistributionGroup 3 | foreach( $group in $groups) 4 | { 5 | if ((Get-DistributionGroupMember $group.identity | select -Expand distinguishedname) -contains $identity.distinguishedname){$group.name} 6 | } -------------------------------------------------------------------------------- /Change-Update User Profiles O365.ps1: -------------------------------------------------------------------------------- 1 | $UpdateCSV | ForEach {Set-MsolUser -UserPrincipalName $_.EMAIL_ADDRESS -FirstName $_.First_Name -LastName $_.Last_Name -Title $_.Title -Office $_.Office -PhoneNumber $_.Office_Phone -StreetAddress $_.Street_address -City $_.City -State $_.State -PostalCode $_.ZIP -Country $_.Country} -------------------------------------------------------------------------------- /Rename-PC.ps1: -------------------------------------------------------------------------------- 1 | #Rename Computer based on set prefix (replace the 2 values in Preold and Prenew ) 2 | 3 | $hn = hostname 4 | $PreOld = 'som' 5 | $PreNew = 'njo' 6 | 7 | $hnNew = $hn.replace("$($PreOld)","$($PreNew)") 8 | $hnNew.ToUpper() 9 | Rename-Computer -NewName $hnNew -Force 10 | 11 | Start-sleep -s 3 -------------------------------------------------------------------------------- /Export-MemberOf.ps1: -------------------------------------------------------------------------------- 1 | $Members = @() 2 | 3 | $Users = Import-csv "C:\CSV\AplicareEmailSamAccountName.csv" 4 | 5 | $Users | ForEach-Object { Get-Aduser -Identity $_.SamAccountName -Properties memberof} | Select Name, @{l="Member Of";e={[string]$_.MemberOf}} #| Export-csv C:\CSV\AplicareUsersMemberOf.csv -Notypeinformation 6 | -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] 5 | -------------------------------------------------------------------------------- /Update-ADUserDisplayName.ps1: -------------------------------------------------------------------------------- 1 | $Users = Get-aduser -filter * -SearchBase "" -properties Displayname 2 | 3 | $dpOld = '(SOM)' 4 | $dpNew = '(NJ)' 5 | 6 | ForEach($User in $Users){ 7 | 8 | $dpNJ = $User.Displayname.replace("$($dpold)","$($dpnew)") 9 | set-aduser -identity $user.samaccountname -Displayname $dpNJ 10 | 11 | } -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/obj/Release/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] 5 | -------------------------------------------------------------------------------- /Intune-IPV6-Disable.ps1: -------------------------------------------------------------------------------- 1 | $Adapter = Get-NetAdapterBinding | where-Object ComponentID -EQ 'ms_tcpip6' | Where-Object Name -notlike "*Bluetooth*" 2 | 3 | Foreach ($Adapt in $Adapter){ 4 | 5 | Disable-netadapterbinding -Name $adapt.name -ComponentID 'ms_tcpip6' 6 | "Disabling $($Adapt.name)'s IPv6" 7 | } -------------------------------------------------------------------------------- /Add-UsertoMultipleDistGroups.ps1: -------------------------------------------------------------------------------- 1 | $Array = Read-Host "Enter Distribution Groups, Separated by a comma" 2 | $Member = Read-Host "Enter the user's Display Name" 3 | 4 | ForEach ($item in $Array) { Add-DistributionGroupMember -Identity $Item -Member $Member -BypassSecurityGroupManagerCheck } 5 | 6 | Get-DistributionGroupMember -Identity $Member -------------------------------------------------------------------------------- /AddUsertoMultipleDistGroups.ps1: -------------------------------------------------------------------------------- 1 | $Array = Read-Host "Enter Distribution Groups, Separated by a comma" 2 | $Member = Read-Host "Enter the user's Display Name" 3 | 4 | ForEach ($item in $Array) { Add-DistributionGroupMember -Identity $Item -Member $Member -BypassSecurityGroupManagerCheck } 5 | 6 | Get-DistributionGroupMember -Identity $Member -------------------------------------------------------------------------------- /Compress-printerarchive.ps1: -------------------------------------------------------------------------------- 1 | $path = 'C:\Temp\Print Drivers\' 2 | 3 | $chitem = Get-childitem $path | select name, Fullname 4 | 5 | Foreach ($Printer in $chitem){ 6 | "Compressing $($Printer.Name) to C:\TCCODrivers\$($Printer.Name).zip" 7 | Compress-Archive $printer.Fullname -DestinationPath "C:\TCCODrivers\$($Printer.Name)" -CompressionLevel Optimal -Force 8 | 9 | } -------------------------------------------------------------------------------- /Report-ActivesyncReport2.ps1: -------------------------------------------------------------------------------- 1 | #Get All Mailboxes 2 | $mailboxes = Get-Mailbox -ResultSize Unlimited 3 | 4 | 5 | #Output File 6 | $OutputFile = "C:\CSV\ActiveSyncUsers.CSV" 7 | 8 | #Loop it 9 | 10 | ForEach ($Mailbox in $mailboxes) { 11 | 12 | $devices = Get-MobileDeviceStatistics -Mailbox $mailbox.samaccountname 13 | 14 | } 15 | 16 | $Devices -------------------------------------------------------------------------------- /SGDList.ps1: -------------------------------------------------------------------------------- 1 | $PCS = Import-csv C:\Temp\PCList.csv 2 | 3 | ForEach($PC in $PCS){ 4 | 5 | $SGDVer = Get-wmiobject -query "SELECT * FROM Win32_Product Where Name Like '%Secure Global Desktop Client%'" -ComputerName $PC.IPAddress 6 | $SGDVer | Select @{Name= "IPAddress"; Expression = {$($PC.IpAddress)}}, Name, Vendor, Version | Export-CSV C:\Temp\SGDOutput.csv -notypeinformation 7 | 8 | } -------------------------------------------------------------------------------- /Report-Get-AdGroupMembers.ps1: -------------------------------------------------------------------------------- 1 | $ADgroups = Get-ADgroup -Filter {Name -like "RG-Excelsior*"} 2 | 3 | ForEach ($AdGroup in $ADgroups) { 4 | 5 | Get-AdgroupMember -Identity $Adgroup.DistinguishedName | Select Name, SamAccountName, @{Name="Security Group"; Expression = {$AdGroup.name}} | Export-csv C:\CSV\ADGroupMembers-RG-$((Get-Date).ToString("MM-dd-yy_hh_mm")).CSV -append -notypeinformation 6 | 7 | } 8 | -------------------------------------------------------------------------------- /Intune/Intune-TestDocRemediaton-Creation.ps1: -------------------------------------------------------------------------------- 1 | #Create txt doc 2 | 3 | $Path = "C:\Temp\" 4 | 5 | if (Test-Path $Path){ 6 | Write-Host ("{0} was found" -f $Path) 7 | }else{ 8 | Write-Host ("{0} was not found, creating path" -f $Path) 9 | New-Item -ItemType Directory -Path $Path | Out-Null 10 | } 11 | 12 | #Create txt doc 13 | New-item -Path "C:\temp\testdoc.txt" -itemType "file" 14 | 15 | exit 1 -------------------------------------------------------------------------------- /TestUserPasswordREset.ps1: -------------------------------------------------------------------------------- 1 | #Test 2 | $Users = Import-CSV C:\CSV\TEst_mac.csv 3 | 4 | ForEach($SamAccountName in $Users) 5 | 6 | { 7 | 8 | Get-Aduser $SamAccountName | Set-AdAccountPassword -Newpassword $pass -reset 9 | 10 | Get-ADuser $SamAccountName | Set-Aduser -ChangePasswordatLogon $False -PasswordNeverExpires $True 11 | 12 | Write-Host "Password has beensreset for the user: $user" 13 | 14 | } -------------------------------------------------------------------------------- /extract-filetobase64.ps1: -------------------------------------------------------------------------------- 1 | # First, let's encode the external file as Base64. Do this once. 2 | $Items = Get-ChildItem 3 | 4 | Foreach($item in $items){ 5 | 6 | $Content = Get-Content -Path "$($item.DirectoryName)\$($Item.name)" -Encoding Byte 7 | $Base64 = [Convert]::ToBase64String($Content) 8 | $Base64 | Out-File "$($pwd.path)\$($item.name).txt" 9 | 10 | 11 | } 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Report-FilesharePermissions_New.ps1: -------------------------------------------------------------------------------- 1 | #Get-ACL for each directory within the USNJFS001 Fileshare 2 | $Filename = 'C:\CSV\usnjfs001-Groups-Permissions.CSV' 3 | 4 | $Paths = "G:\*" 5 | 6 | $ACL = Get-ACL -Path $Paths 7 | 8 | $ACL | Select PSDrive, PSChildName, PSPath -ExpandProperty Access| export-csv $Filename 9 | 10 | Write-Host " Complete" -ForegroundColor green 11 | Write-Host "Your file has been saved to $Filename" -------------------------------------------------------------------------------- /FindNextAvailableLoop.ps1: -------------------------------------------------------------------------------- 1 | 2 | $CompName = Get-adcomputer -filter {Name -like "NJOLAP*"} | Select Name 3 | $i = 1 4 | 5 | 6 | ForEach($PCName in $CompName){ 7 | "Searching for a free hostname $($PCName.Name)" 8 | 9 | while(($Match = "NJOLAP$('{0:d4}' -f $i)") -eq $($PCName.Name)){ 10 | "$Match is True, Keep Looking" 11 | $i++ 12 | } 13 | "$Match is False, We can use this!" 14 | $i++ 15 | 16 | } -------------------------------------------------------------------------------- /Development/Remove-UserFromDistroIfDisabled.ps1: -------------------------------------------------------------------------------- 1 | $Members = Get-ADGroupMember -Identity "All Excelsior Employees" 2 | 3 | ForEach($Member in $members){ 4 | 5 | $DisabledUsers = Get-ADuser -Identity $Member.SamAccountName -property emailaddress 6 | $NoEmail = Get-aduser -Filter {Emailaddress -Notlike "*"} -Properties Emailaddress 7 | 8 | ForEach($NoE in $noemail){ 9 | 10 | $NoE.SamAccountName 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace Percent_Change 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BulkCreate-Users.ps1: -------------------------------------------------------------------------------- 1 | #Create users in bulk with a CSV File for Office 365 2 | 3 | $Path = Read-Host "Please copy the path of the CSV file for the user accounts" 4 | 5 | Import-CSV -Path "$Path" | ForEach-Object { New-Msoluser -UserPrincipalName $_.Email -FirstName $_.First -LastName $_.Last -DisplayName $_.DisplayName -Title $_.Title -Office $_.Office -PhoneNumber $_.Office_Phone -StreetAddress $_.Street_Address -City $_.City -State $_.State -PostalCode $_.Zip -Password } -------------------------------------------------------------------------------- /Add-DistributionGroupMember.ps1: -------------------------------------------------------------------------------- 1 | $member = Read-Host "Enter a User" 2 | 3 | do { 4 | 5 | $DistGroup = Read-Host "Enter Distribution Group Keyword" 6 | Get-DistributionGroup -Anr "$DistGroup" | Format-Table Name,PrimarySMTPAddress 7 | $Group = Read-Host "Enter Distribution Groups" 8 | 9 | Add-DistributionGroupMember -Identity "$Group" -Member "$Member" -BypassSecurityGroupManagerCheck 10 | 11 | $response = Read-Host "Repeat? (Y/N):" 12 | } 13 | while ($response -eq "y") 14 | -------------------------------------------------------------------------------- /Create-BulkCreate-Users.ps1: -------------------------------------------------------------------------------- 1 | #Create users in bulk with a CSV File for Office 365 2 | 3 | $Path = Read-Host "Please copy the path of the CSV file for the user accounts" 4 | 5 | Import-CSV -Path "$Path" | ForEach-Object { New-Msoluser -UserPrincipalName $_.Email -FirstName $_.First -LastName $_.Last -DisplayName $_.DisplayName -Title $_.Title -Office $_.Office -PhoneNumber $_.Office_Phone -StreetAddress $_.Street_Address -City $_.City -State $_.State -PostalCode $_.Zip -Password AHEuser123$ } -------------------------------------------------------------------------------- /Report-AccountSKU_List.ps1: -------------------------------------------------------------------------------- 1 | $i = 0 2 | 3 | Get-MsolAccountSku 4 | 5 | do 6 | { 7 | 8 | Write-Host "$i, $($SKU[$i].AccountSkuId)" 9 | $i++ 10 | } 11 | 12 | While($i -le $Sku.count-1) 13 | 14 | [int]$userChoice = Read-Host "Please select the license to export." 15 | 16 | ForEach($User in $Users) 17 | 18 | { 19 | 20 | $users = Get-Msoluser | Where { $_.Licenses.accountskuid -like "*$($sku[$i].AccountSkuID)*"} 21 | 22 | } -------------------------------------------------------------------------------- /User Access Report.ps1: -------------------------------------------------------------------------------- 1 | 2 | $site = Get-SPSite https://newleafflorida-admin.sharepoint.com 3 | $web = $site.OpenWeb() 4 | $groups = $web.sitegroups 5 | 6 | foreach ($grp in $groups) { 7 | "Group: " + $grp.name; 8 | $groupName = $grp.name 9 | write-host "Group: " $groupName -foregroundcolor green 10 | foreach ($user in $grp.users) { 11 | "User: " + $user.name 12 | write-host "User " $user.UserLogin -foregroundcolor red 13 | } 14 | } -------------------------------------------------------------------------------- /Report-User Access Report.ps1: -------------------------------------------------------------------------------- 1 | 2 | $site = Get-SPSite https://newleafflorida-admin.sharepoint.com 3 | $web = $site.OpenWeb() 4 | $groups = $web.sitegroups 5 | 6 | foreach ($grp in $groups) { 7 | "Group: " + $grp.name; 8 | $groupName = $grp.name 9 | write-host "Group: " $groupName -foregroundcolor green 10 | foreach ($user in $grp.users) { 11 | "User: " + $user.name 12 | write-host "User " $user.UserLogin -foregroundcolor red 13 | } 14 | } -------------------------------------------------------------------------------- /Try-Catch-Final_Test.ps1: -------------------------------------------------------------------------------- 1 | #Try Catch Finally Test 2 | 3 | $PrintCSV = Import-csv C:\CSV\PrinterExport.csv 4 | 5 | $Server = "NEPPRDPRINT1" 6 | 7 | try { 8 | ForEach($Printer in $PrintCSV){ 9 | 10 | Get-Printer -ComputerName $Server -Name $Printer.Name -ErrorAction SilentlyContinue 11 | #$Error | Export-csv C:\csv\Errors.csv -append 12 | } 13 | } 14 | 15 | catch { 16 | 17 | "Printer Not Available Logging: $_" | Add-Content C:\CSV\ErrorLog.txt 18 | } 19 | 20 | -------------------------------------------------------------------------------- /BulkAdd-DistMembers.ps1: -------------------------------------------------------------------------------- 1 | do { 2 | 3 | $DistGroup = Read-Host "Please Enter the DisplayName of the Distribution Group" 4 | $CSVPath = Read-Host "Please Paste the full path to the CSV file (Including the file itself)" 5 | 6 | Import-CSV -Path "$CSVPath" | ForEach-Object { Add-DistributionGroupMember -Identity "$DistGroup" -Member $_.members} 7 | 8 | Get-DistributionGroupMember -Identity "$Distgroup" 9 | 10 | $response = Read-Host "Again? (Y/N):" 11 | 12 | } 13 | 14 | while ($response -eq "y") -------------------------------------------------------------------------------- /Add-BulkAdd-DistMembers.ps1: -------------------------------------------------------------------------------- 1 | do { 2 | 3 | $DistGroup = Read-Host "Please Enter the DisplayName of the Distribution Group" 4 | $CSVPath = Read-Host "Please Paste the full path to the CSV file (Including the file itself)" 5 | 6 | Import-CSV -Path "$CSVPath" | ForEach-Object { Add-DistributionGroupMember -Identity "$DistGroup" -Member $_.members} 7 | 8 | Get-DistributionGroupMember -Identity "$Distgroup" 9 | 10 | $response = Read-Host "Again? (Y/N):" 11 | 12 | } 13 | 14 | while ($response -eq "y") -------------------------------------------------------------------------------- /Change-ForceChangePassword_False.ps1: -------------------------------------------------------------------------------- 1 | Import-MOdule ActiveDirectory 2 | $location = Get-location 3 | 4 | if ($location -ne "AD:\OU=TMS Users,OU=HQ,DC=excelsior,DC=local" ) { 5 | Set-Location AD: 6 | Set-location "OU=TMS Users,OU=HQ,DC=excelsior,DC=local" 7 | Get-Aduser -Filter * | ForEach{ Set-Aduser $_.SamAccountName -ChangePasswordAtLogon $False } 8 | 9 | } 10 | else { 11 | Get-Aduser -Filter * | ForEach{ Set-Aduser $_.SamAccountName -ChangePasswordAtLogon $False } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /RemoveUserDist.ps1: -------------------------------------------------------------------------------- 1 | $user = $args[0] 2 | if (!$args[0]) { 3 | 4 | } 5 | $mailbox=get-mailbox $user 6 | 7 | $dgs= Get-DistributionGroup 8 | 9 | foreach($dg in $dgs){ 10 | 11 | $DGMs = Get-DistributionGroupMember -identity $dg.Identity 12 | foreach ($dgm in $DGMs){ 13 | if ($dgm.name -eq $mailbox.name){ 14 | 15 | write-host 'User Found In Group' $dg.identity 16 | Remove-DistributionGroupMember $dg.Name -Member $user -Confirm:$False 17 | 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Remove-DistributionGroupMemberfromAll.ps1: -------------------------------------------------------------------------------- 1 | $user = $args[0] 2 | if (!$args[0]) { 3 | 4 | } 5 | $mailbox = get-mailbox $user 6 | 7 | $dgs= Get-DistributionGroup 8 | 9 | foreach($dg in $dgs){ 10 | 11 | $DGMs = Get-DistributionGroupMember -identity $dg.Identity 12 | foreach ($dgm in $DGMs){ 13 | if ($dgm.name -eq $mailbox.name){ 14 | 15 | write-host 'User Found In Group' $dg.identity 16 | Remove-DistributionGroupMember $dg.Name -Member $user 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /Remove-UserDist.ps1: -------------------------------------------------------------------------------- 1 | $user = $args[0] 2 | if (!$args[0]) { 3 | 4 | } 5 | $mailbox=get-mailbox $user 6 | 7 | $dgs= Get-DistributionGroup 8 | 9 | foreach($dg in $dgs){ 10 | 11 | $DGMs = Get-DistributionGroupMember -identity $dg.Identity 12 | foreach ($dgm in $DGMs){ 13 | if ($dgm.name -eq $mailbox.name){ 14 | 15 | write-host 'User Found In Group' $dg.identity 16 | Remove-DistributionGroupMember $dg.Name -Member $user -Confirm:$False 17 | 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Intune/Intune-TestDocRemediaton.ps1: -------------------------------------------------------------------------------- 1 | $files = @( 2 | "testdoc.txt" 3 | ) 4 | 5 | $Path = "C:\Temp\" 6 | 7 | $badcount = 0 8 | foreach ($file in $files){ 9 | if (Test-Path "$Path\$file"){ 10 | Write-host ("{0} was found" -f $file) 11 | 12 | } 13 | else { 14 | Write-host ("{0} was found" -f $file) 15 | $badcount++ 16 | } 17 | } 18 | 19 | IF ($badcount -gt 0){ 20 | Write-host ("Not all files were not found") 21 | exit 1 22 | } 23 | else { 24 | Write-host ("All files were found") 25 | exit 0 26 | } -------------------------------------------------------------------------------- /Development/Fileshare Maintenance.ps1: -------------------------------------------------------------------------------- 1 | #Checks AD For a list of Users, takes their SamAccountName, compares with the list of U drives, if a User exists in AD but not the fileshare, create and share the fileshare 2 | #If the fileshare has a folder that AD does not, move the folder to _Archive 3 | 4 | #By Ryan Curran 5 | #7/10/19 6 | 7 | $Users = Get-aduser -Filter * -SearchBase "OU=Users,OU=US_Excelsior_Medical_Neptune_NJ,OU=Users_And_Computers,DC=medline,DC=com" 8 | $UDriveList = Get-Childitem -Path "\\usnjfs001\H$" -exclude _Archive,Batch,Kioware$ 9 | 10 | -------------------------------------------------------------------------------- /Self-Elevate.ps1: -------------------------------------------------------------------------------- 1 | # Self-elevate the script if required 2 | if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { 3 | if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { 4 | $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments 5 | Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine 6 | Exit 7 | } 8 | } 9 | #Put code below -------------------------------------------------------------------------------- /Change-BulkPW_Reset.ps1: -------------------------------------------------------------------------------- 1 | Function Get-FileName 2 | { 3 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 4 | 5 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 6 | #$OpenFileDialog.initialDirectoiry = $initialDirectory 7 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 8 | $OpenFileDialog.ShowDialog() | Out-Null 9 | } 10 | 11 | $CSV = Get-Filename 12 | 13 | $CSV | ForEach{ Set-ADAccountPassword -Identity "$_.Sam" -reset -NewPassword (ConvertTo-SecureString -AsPlainText "$_.Pass") } -------------------------------------------------------------------------------- /Test-ValidateScript.ps1: -------------------------------------------------------------------------------- 1 | $HN = Import-csv C:\csv\Hosts.csv 2 | 3 | ForEach($HNs in $HN){ 4 | 5 | $tF = Test-Connection $($Hns.Hostname) -quiet -Count 1 -ErrorAction Stop 6 | 7 | if ($tF -eq $True){ 8 | 9 | #Write code to execute 10 | $Hns.Hostname 11 | 12 | }else { 13 | #Export your hostnames that failed the ping 14 | $Hns.Hostname | Export-csv C:\CSV\Failures.csv -append notypeinformation 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /TestCheck.ps1: -------------------------------------------------------------------------------- 1 | function Check-IsElevated 2 | { 3 | $id = [System.Security.Principal.WindowsIdentity]::GetCurrent() 4 | $p = New-Object System.Security.Principal.WindowsPrincipal($id) 5 | if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)) 6 | { Write-Output $true, 7 | "You're Set" } 8 | else 9 | { Write-Output $false 10 | "Saving Path" 11 | $location = get-location 12 | Start-process powershell -verb runas -ArgumentList @("cd $($location.path)") } 13 | } 14 | 15 | 16 | Check-IsElevated 17 | -------------------------------------------------------------------------------- /Set-UserAccess.ps1: -------------------------------------------------------------------------------- 1 | #Get user input 2 | $User = Read-Host "User(Email)" 3 | $Status = Read-Host "Set Status (True (Blocked) or False (Not Blocked))" #True will block access, False will allow access 4 | 5 | #IF statement for true or false. 6 | IF($Status -eq "True"){ 7 | 8 | Set-Msoluser -UserPrincipalName $User -BlockCredential $True 9 | 10 | } 11 | 12 | #If not true, and if $Status is equal to False then proceed. 13 | ElseIf($Status -eq "False"){ 14 | 15 | Set-MsolUser -UserPrincipalName $User -BlockCredential $False 16 | 17 | } 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Template-DetectionScriptIntune.ps1: -------------------------------------------------------------------------------- 1 | $Path = $Env:programdata 2 | 3 | $RC1 = Test-Path -Path $Path'%programdata%\TurnerDetection\VC2010-10.0.40219.325.txt' -PathType Leaf 4 | $RC2 = Test-Path -Path $Path'%programdata%\TurnerDetection\VC2012-11.0.61030.0.txt' -PathType Leaf 5 | $RC3 = Test-Path -Path $Path'%programdata%\TurnerDetection\VC2013-12.0.40664.0.txt' -PathType Leaf 6 | 7 | If ( $RC1 -and $RC2 -and $RC3 ) { 8 | Write-Output "Detection Successful" 9 | EXIT 0 10 | } ELSE { 11 | Write-Output "Detection Failed: RC1 = $($RC1), RC2 = $($RC2), RC3 = $($RC3)" 12 | EXIT 1 -------------------------------------------------------------------------------- /Remove-ADGroupMembers-ConvertDisplaynamesFirst.ps1: -------------------------------------------------------------------------------- 1 | $users = Import-CSV C:\CSV\MDB1xxusers.csv 2 | 3 | ForEach ($user in $users) { 4 | 5 | $dn = $user.DisplayName 6 | 7 | Get-Aduser -Filter { displayName -like $dn} | select samaccountname | export-csv C:\CSV\MDB1Converts.csv -append -NoTypeInformation 8 | 9 | 10 | } 11 | <# 12 | $samacc = Import-CSV C:\CSV\MDB1Converts.csv 13 | 14 | ForEach ($samaccs in $samacc) { 15 | 16 | $san = $samaccs.SamAccountName 17 | 18 | Remove-ADGroupMember -Identity evprepenable -Members $_.SamAccountName 19 | 20 | } 21 | #> -------------------------------------------------------------------------------- /Elevate-Session_runAs.ps1: -------------------------------------------------------------------------------- 1 | "Checking to for an elevated powershell session (Administrator)" 2 | if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { 3 | if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { 4 | $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments 5 | Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine 6 | Exit 7 | } 8 | } -------------------------------------------------------------------------------- /Export-ADGROUPMEMBERS_2022.ps1: -------------------------------------------------------------------------------- 1 | #Prompt user for group name 2 | Write-Host "Enter a security group " -ForegroundColor Red -NoNewLine 3 | $GroupName = Read-Host 4 | Write-host "$GroupName has been selected" -ForegroundColor Green -BackgroundColor Black 5 | 6 | 7 | Get-ADGroupMember -Identity $GroupName -Recursive | 8 | Get-ADUser -Properties physicaldeliveryofficename | 9 | Select Name,ObjectClass,SamAccountName,physicaldeliveryofficename | 10 | Sort-Object Name | 11 | Export-Excel "c:\temp\$($GroupName)_$([DateTime]::Now.ToSTring("MM-dd-yyyy hhmm tt")).xlsx" -TableStyle Light1 -AutoSize -Append -------------------------------------------------------------------------------- /Function_Get-LoggedOnUser-ValidateScript.ps1: -------------------------------------------------------------------------------- 1 | function Get-LoggedOnUser 2 | { 3 | [CmdletBinding()] 4 | param 5 | ( 6 | [Parameter()] 7 | [ValidateScript({ Test-Connection -ComputerName $_ -Quiet -Count 1 })] 8 | [ValidateNotNullOrEmpty()] 9 | [string[]]$ComputerName = $env:COMPUTERNAME 10 | ) 11 | foreach ($comp in $ComputerName) 12 | { 13 | $output = @{ 'ComputerName' = $comp } 14 | $output.UserName = (Get-WmiObject -Class win32_computersystem -ComputerName $comp).UserName 15 | [PSCustomObject]$output 16 | } 17 | } -------------------------------------------------------------------------------- /Change-User Login Status(Block-Allow).ps1: -------------------------------------------------------------------------------- 1 | #Get user input 2 | $User = Read-Host "User(Email)" 3 | $Status = Read-Host "Set Status (True (Blocked) or False (Not Blocked))" #True will block access, False will allow access 4 | 5 | #IF statement for true or false. 6 | IF($Status -eq "True"){ 7 | 8 | Set-Msoluser -UserPrincipalName $User -BlockCredential $True 9 | 10 | } 11 | 12 | #If not true, and if $Status is equal to False then proceed. 13 | ElseIf($Status -eq "False"){ 14 | 15 | Set-MsolUser -UserPrincipalName $User -BlockCredential $False 16 | 17 | } 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Create-LocalUser Accounts CSV.ps1: -------------------------------------------------------------------------------- 1 | Function Get-FileName($InitialDirectory) 2 | { 3 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 4 | 5 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 6 | $OpenFileDialog.initialDirectory = $initialDirectory 7 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 8 | $OpenFileDialog.ShowDialog() | Out-Null 9 | $OpenFileDialog.FileName 10 | } 11 | 12 | 13 | $Path = Get-FileName 14 | 15 | $Path | ForEach-Object { 16 | 17 | Net User $_.SamAccountName $_.Password /Add 18 | 19 | } -------------------------------------------------------------------------------- /Change-MailboxCopyAndForward.ps1: -------------------------------------------------------------------------------- 1 | #Deliver to Mailbox and forward turned off 2 | 3 | Function Get-FileName 4 | { 5 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 6 | 7 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 8 | #$OpenFileDialog.initialDirectoiry = $initialDirectory 9 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 10 | $OpenFileDialog.ShowDialog() | Out-Null 11 | } 12 | 13 | $CSV = Get-Filename 14 | 15 | Import-CSV "$CSV" | ForEach-Object(Set-Mailbox -Identity $_.UserPrincipalName -DeliverTomailboxandforward $False) -------------------------------------------------------------------------------- /Move-IconsToNewPC.ps1: -------------------------------------------------------------------------------- 1 | 2 | $NewPC = Read-Host "Enter the new PC HOSTNAME(Ex: NEP12345)" 3 | $User = Read-Host "Enter the users login name (Ex: Jsmith12345)" 4 | $PAUser = Read-Host "Enter your PA username" 5 | $Cred = Get-Credential -Username "Medline-nt\$PaUser" -Message "Fill out PA Credentials" 6 | 7 | New-PSDrive -Name H -PSProvider FileSystem -Root "\\$newPC\c$" -Credential $Cred 8 | Write-Host "Drive Mounted " 9 | Copy-Item "C:\Users\$User\Desktop\*" "H:\Users\$User\Desktop\" -Recurse 10 | Write-Host "Items copied" 11 | Remove-PSDrive -Name H 12 | Write-Host "Drive Removed" 13 | Write-Host "Move Complete" 14 | Pause -------------------------------------------------------------------------------- /TestPS1.ps1: -------------------------------------------------------------------------------- 1 | Function Get-FileName 2 | { 3 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 4 | 5 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 6 | $OpenFileDialog.initialDirectory = $initialDirectory 7 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 8 | $OpenFileDialog.ShowDialog() #| Out-Null 9 | $OpenFileDialog.FileName 10 | } 11 | 12 | $CSVFiles = Get-Childitem C:\Powershell -Filter *.csv | out-gridview -Outputmode Multiple 13 | 14 | Foreach ($File in $CSVFiles) { 15 | 16 | $Userdata = import-csv $File 17 | 18 | } -------------------------------------------------------------------------------- /Create-LocalUser_Accounts_CSV.ps1: -------------------------------------------------------------------------------- 1 | Function Get-FileName($InitialDirectory) 2 | { 3 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 4 | 5 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 6 | $OpenFileDialog.initialDirectory = $initialDirectory 7 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 8 | $OpenFileDialog.ShowDialog() | Out-Null 9 | $OpenFileDialog.FileName 10 | } 11 | 12 | 13 | $Path = Get-FileName 14 | 15 | Import-CSV $Path | ForEach-Object { 16 | 17 | Net User $_.SamAccountName $_.Password /Add 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Report-ADGROUPMEMBERS.ps1: -------------------------------------------------------------------------------- 1 | Get-ADgroup -Filter {Name -like "NJO.BUS.ALL*"} -PipelineVariable group | 2 | Get-AdgroupMember -PipelineVariable member | ForEach-Object { 3 | New-Object psobject -Property @{ 4 | Group = $group.Name 5 | "Group DN" = $group.Distinguishedname 6 | "Group SamAccountName" = $group.SamAccountName 7 | "Member DN" = $member.DistinguishedName 8 | "Member Name" = $member.Name 9 | "Member SamAccountName" = $member.SamAccountName 10 | } | Export-CSV C:\Temp\ADGroupMembers-$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv -Append -NoTypeInformation 11 | } -------------------------------------------------------------------------------- /Sharepoint_Email_Import.ps1: -------------------------------------------------------------------------------- 1 | Function Get-FileName($InitialDirectory) 2 | { 3 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 4 | 5 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 6 | $OpenFileDialog.initialDirectory = $initialDirectory 7 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 8 | $OpenFileDialog.ShowDialog() | Out-Null 9 | $OpenFileDialog.FileName 10 | } 11 | 12 | $Path = Get-FileName 13 | 14 | $Path | ForEach-Object { 15 | 16 | Set-SPUser -Identity "Medline-NT\$_.SamAccountName" -Email "$_.UserPrincipalName" -Web http://Intranet 17 | 18 | } -------------------------------------------------------------------------------- /Install-SOMPrinters.vbs: -------------------------------------------------------------------------------- 1 | Option Explicit 2 | Dim netPrinter, UNCpath, UNCpath1, UNCpath2 3 | UNCpath = "\\SOMPRNT2\som.bus.main.laniercolor8003" 4 | UNCpath1 = "\\somprnt2\SOM.BUS.MAIN.RICOH9003" 5 | UNCpath2 = "\\somprnt2\SOM.BUS.MAIN.PLOT.HP3500" 6 | Set netPrinter = CreateObject("WScript.Network") 7 | netPrinter.AddWindowsPrinterConnection UNCpath 8 | WScript.Echo "Your printer is mapped from : " & UNCpath 9 | netPrinter.AddWindowsPrinterConnection UNCpath1 10 | WScript.Echo "Your printer is mapped from : " & UNCpath1 11 | netPrinter.AddWindowsPrinterConnection UNCpath2 12 | WScript.Echo "Your printer is mapped from : " & UNCpath2 13 | 14 | WScript.Quit 15 | -------------------------------------------------------------------------------- /Report-Get-ADusers-MultipleOUs.ps1: -------------------------------------------------------------------------------- 1 | ##################################### 2 | ## Ryan Curran ## 3 | ## 8/23/17 ## 4 | ##Collect Users from Multiple OU's ## 5 | ##################################### 6 | 7 | Import-Module ActiveDirectory 8 | 9 | Set-location AD: 10 | 11 | 'OU=Users,OU=HQ,DC=Excelsior,DC=Local','OU=Users,OU=US_Excelsior_Medical_Neptune_NJ,OU=Users_And_Computers,DC=Excelsior, DC=Local' ` 12 | | ForEach-Object { Get-Aduser -Filter * -SearchBase $_ -Properties GivenName,EmailAddress,SamAccountName,Name } ` 13 | | where { $_.Enabled -eq $True} | Export-CSV C:\CSV\MultipleOUExport-Excelsior.csv -NoTypeInformation 14 | -------------------------------------------------------------------------------- /Open-RemoteExplorers.ps1: -------------------------------------------------------------------------------- 1 | #Reference Change-BulkPW_Reset.ps1 for more details on a finished script. 2 | 3 | Function Get-FileName($InitialDirectory) 4 | { 5 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 6 | 7 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 8 | $OpenFileDialog.initialDirectory = $initialDirectory 9 | #$OpenFileDialog.filter = "CSV (*.csv) | *.csv" 10 | $OpenFileDialog.ShowDialog() | Out-Null 11 | $OpenFileDialog.FileName 12 | } 13 | 14 | $Comps = Get-FileName 15 | 16 | $PCS = Import-CSV $Comps 17 | 18 | 19 | ForEach ($PC in $PCS){ 20 | $PC 21 | explorer.exe \\$PC\C$\Users\Public\Desktop\ 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Report-Group_and_users.ps1: -------------------------------------------------------------------------------- 1 | Import-module activedirectory 2 | 3 | # "OU=Role,OU=Groups,OU=Special,DC=excelsior,DC=local" 4 | # "OU=FileShares,OU=Security,OU=Groups,OU=Special,DC=excelsior,DC=local" 5 | # "OU=Users,OU=US_Excelsior_Medical_Neptune_NJ,OU=Users_And_Computers,DC=excelsior,DC=local" 6 | # 7 | 8 | $result = @() 9 | $ou = "OU=FileShares,OU=Security,OU=Groups,OU=Special,DC=excelsior,DC=local" 10 | 11 | 12 | Get-ADGroup -Filter * -SearchBase $OU | select -ExpandProperty name | % { 13 | $group= "$_" 14 | $result += Get-ADGroupMember -identity "$_" | select @{n="Group";e={$group}},Name 15 | } 16 | $result | export-csv 'C:\CSV\Roles-membership_03-10-17.csv' -notypeinformation -------------------------------------------------------------------------------- /Shell-ChooseDirectoryExport.ps1: -------------------------------------------------------------------------------- 1 | 2 | #Directory selection for report Import/export 3 | Function Get-FolderName($InitialDirectory) 4 | { 5 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 6 | 7 | $OpenFolderDialog = New-Object System.Windows.Forms.FolderBrowserDialog 8 | #initialize variable $initialDirectory if you'll always be looking in the same location. 9 | #$OpenFolderDialog.initialDirectory = $initialDirectory 10 | #Change the extension or uncomment to change what it filters by, if at all. 11 | #$OpenFileDialog.filter = "CSV (*.csv) | *.csv" 12 | $OpenFolderDialog.ShowDialog() | Out-Null 13 | $OpenFolderDialog.SelectedPath 14 | } 15 | -------------------------------------------------------------------------------- /Template-Foldercreations-Turner.ps1: -------------------------------------------------------------------------------- 1 | #Write this to create C:\Temp and other folders C:\ProgramData\TurnerLogs C:\ProgramData\TurnerDetection 2 | 3 | $Path = "C:\Temp\" 4 | 5 | $badcount = 0 6 | foreach ($file in $files){ 7 | if (Test-Path "$Path"){ 8 | Write-output ("{0} was found" -f $file) 9 | 10 | } 11 | else { 12 | Write-output ("{0} was found" -f $file) 13 | $badcount++ 14 | } 15 | } 16 | 17 | IF ($badcount -gt 0){ 18 | Write-output ("Folder not found, creating $Path.") 19 | 20 | New-Item -Path "C:\Path\To\Your\Folder" -ItemType Directory 21 | 22 | exit 1 23 | } 24 | else { 25 | Write-output ("Folder was found") 26 | exit 0 27 | } -------------------------------------------------------------------------------- /Report-Get-ADGroup - Excelsior Roles.ps1: -------------------------------------------------------------------------------- 1 | Import-Module ActiveDirectory 2 | 3 | Set-location AD: 4 | 5 | while($local.path -ne "AD:\"){ 6 | 7 | cd .. 8 | 9 | $local = Get-Location 10 | 11 | } 12 | 13 | Set-location "OU=Role,OU=Groups,OU=Special,DC=medline,DC=com" 14 | 15 | cls 16 | 17 | Get-ADgroup -Filter * | Where{ $_.Name -like "RG-Excelsior*"} | select Name, DistinguishedName, GroupCategory, GroupScope | Export-CSV "C:\CSV\Excelsior Role Groups - Exported $([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv" -NoTypeInformation 18 | cls 19 | Write-Host "Report Has Been Created. It is named Excelsior Role Groups - Exported $([DateTime]::Now.ToSTring("MM-dd-yyyy-hh.mm.ss")).csv" -------------------------------------------------------------------------------- /ChoicesTest.ps1: -------------------------------------------------------------------------------- 1 | $Title = "" 2 | $Info = Write-host "Would you like to scan directories, files or both? (Please note, scanning for both will drastically increase your scantime)" -Foregroundcolor Yellow -Backgroundcolor Black 3 | 4 | $options = [System.Management.Automation.Host.ChoiceDescription[]] @("&1. Directories", "&2. Files", "&3. Both (Directories & Files)", "&4. Quit") 5 | [int]$defaultchoice = 0 6 | $opt = $host.UI.PromptForChoice($Title, $Info , $Options,$defaultchoice) 7 | switch($opt) 8 | { 9 | 0 { Write-Host "Directories" -ForegroundColor Green} 10 | 1 { Write-Host "Files" -ForegroundColor Green} 11 | 2 { Write-Host "Both" -ForegroundColor Green} 12 | 3 {Write-Host "Quit" -ForegroundColor Green} 13 | } 14 | -------------------------------------------------------------------------------- /Development/Remove-Orphanedpermissions.ps1: -------------------------------------------------------------------------------- 1 | $UDL = Get-Childitem -Path "\\USNJFS001\H$\" 2 | 3 | $i = 0 4 | 5 | ForEach ($UDList in $UDL){ 6 | $Perc = $i/$UDL.Count*100 7 | Write-progress -Activity "Removing Orphaned SID's" -Status "$i Complete of $($UDL.Count)" -PercentComplete $Perc; 8 | 9 | $Perms = Get-NTFSACCESS -PAth "\\USNJFS001\H$\$($UDList.Name)" | Where {$_.Account -like "S-1*"} 10 | "Processing $($UDList.Name)" 11 | 12 | ForEach($Perm in $Perms){ 13 | 14 | "Removing $($Perm.Account) for $($UDList.Name)" 15 | Remove-NTFSAccess -Path "\\USNJFS001\H$\$($UDLIST.Name)" -Account $Perm.Account -AccessRights $Perm.AccessRights 16 | 17 | } 18 | 19 | $i++ 20 | 21 | } -------------------------------------------------------------------------------- /Shell-DialogBox.ps1: -------------------------------------------------------------------------------- 1 | #Reference Change-BulkPW_Reset.ps1 for more details on a finished script. 2 | 3 | Function Get-FileName($InitialDirectory) 4 | { 5 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 6 | 7 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 8 | $OpenFileDialog.dereferencelinks = $False #Make $True is you want to address of the shortcut rather than the path 9 | $OpenFileDialog.initialDirectory = $initialDirectory 10 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 11 | $OpenFileDialog.ShowDialog() | Out-Null 12 | $OpenFileDialog.FileName 13 | } 14 | 15 | $Path = Get-FileName 16 | 17 | $IPath = Import-CSV "$Path" 18 | 19 | $IPath -------------------------------------------------------------------------------- /DistributionGroupMembership.ps1: -------------------------------------------------------------------------------- 1 | function Get-365UserGroupMembership { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory=$true)] 5 | [Alias('Email')] 6 | [string]$UserName 7 | ) 8 | $groups = Get-Group | Where-Object -FilterScript {$_.Members -contains $UserName} 9 | 10 | foreach ($group in $groups) { 11 | $props = @{'Name' = $group.Name; 12 | 'DisplayName' = $group.DisplayName; 13 | 'Identity' = $group.SamAccountName; 14 | 'PrimaryEmail' = $group.WindowsEmailAddress} 15 | 16 | $obj = New-Object -TypeName PSObject -Property $props 17 | Write-Output $obj 18 | } 19 | } -------------------------------------------------------------------------------- /Report-DistributionGroupMembership.ps1: -------------------------------------------------------------------------------- 1 | function Get-365UserGroupMembership { 2 | [CmdletBinding()] 3 | Param( 4 | [Parameter(Mandatory=$true)] 5 | [Alias('Email')] 6 | [string]$UserName 7 | ) 8 | $groups = Get-msolgroup | Where-Object -FilterScript {$_.Members -contains $UserName} 9 | 10 | foreach ($group in $groups) { 11 | $props = @{'Name' = $group.Name; 12 | 'DisplayName' = $group.DisplayName; 13 | 'Identity' = $group.SamAccountName; 14 | 'PrimaryEmail' = $group.WindowsEmailAddress} 15 | 16 | $obj = New-Object -TypeName PSObject -Property $props 17 | Write-Output $obj 18 | } 19 | } -------------------------------------------------------------------------------- /Install-SharepointPnPModule.ps1: -------------------------------------------------------------------------------- 1 | #Run to install SharepointPnPOnline Module 2 | Invoke-Expression (New-Object -TypeName Net.WebClient).DownloadString('https://raw.githubusercontent.com/officedev/PnP-PowerShell/master/Samples/Modules.Install/Install-PowerShellPackageMangement.ps1') # We use this to install the PowerShell Package Manager for the PowerShell Gallery 3 | Invoke-Expression (New-Object -TypeName Net.WebClient).DownloadString('https://raw.githubusercontent.com/officedev/PnP-PowerShell/master/Samples/Modules.Install/Install-SharePointPnPPowerShellHelperModule.ps1') 4 | #Updates the Module after being installed 5 | Update-module Sharepointpnppowershell* -force 6 | #Ready to Run. Test by typing Connect-Pnpo and pressing Tab to see if it auto completes the command. -------------------------------------------------------------------------------- /Report-Asset_To_User_1.ps1: -------------------------------------------------------------------------------- 1 | $Node = Import-csv C:\CSV\Test.csv 2 | 3 | ForEach ($nodes in $node) { 4 | 5 | Write-host "Attempting to lookup" $Nodes.Hostname 6 | 7 | $UName = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_ComputerSystem | Select-Object UserName 8 | $HN = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_ComputerSystem | Select-Object PSComputerName 9 | $OS = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_OperatingSystem | Select-Object Caption 10 | 11 | 12 | New-Object -Typename PSCustomObject -Property @{ 13 | "UserName" = $($UName.Username) 14 | "Hostname" = $($HN.PSComputername) 15 | "OS" = $($OS.Caption) 16 | 17 | 18 | } | Export-csv -Path C:\CSV\UserInfo.csv -NoTypeInformation -Append 19 | 20 | } -------------------------------------------------------------------------------- /Report-Get-ADGroup - Excelsior Fileshare Groups.ps1: -------------------------------------------------------------------------------- 1 | Import-Module ActiveDirectory 2 | 3 | Set-location AD: 4 | 5 | while($local.path -ne "AD:\"){ 6 | 7 | cd .. 8 | 9 | $local = Get-Location 10 | 11 | } 12 | 13 | Set-location "OU=FileShares,OU=Security,OU=Groups,OU=Special,DC=medline,DC=com" 14 | 15 | cls 16 | 17 | Get-ADgroup -Filter * | Where{ $_.Name -like "SD-FS-USNJFS001*" -or $_.Name -like "SD-FS-NEP*"} | select Name, DistinguishedName, GroupCategory, GroupScope | Export-CSV "C:\CSV\Excelsior Fileshare Groups - Exported $([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv" -NoTypeInformation 18 | cls 19 | Write-Host "Report Has Been Created. It is named Excelsior Fileshare Groups - Exported $([DateTime]::Now.ToSTring("MM-dd-yyyy-hh.mm.ss")).csv" -------------------------------------------------------------------------------- /Add-FullAccess.ps1: -------------------------------------------------------------------------------- 1 | #Grant Full Access to All user Mailboxes in Office 365 2 | 3 | #Open Dialog box 4 | # Get-Mailbox | Add-mailboxpermission -user Alan@domain.com -AccessRights FullAccess 5 | 6 | Function Get-FileName 7 | { 8 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 9 | 10 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 11 | #$OpenFileDialog.initialDirectoiry = $initialDirectory 12 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 13 | $OpenFileDialog.ShowDialog() | Out-Null 14 | } 15 | 16 | $CSV = Get-Filename 17 | 18 | $CSV | ForEach(Add-MailboxPermission -identity $_.UserPrincipalName -User rcurran@excelsiormedical.com -AccessRights fullaccess -InheritanceType all) -------------------------------------------------------------------------------- /Archive/Restore-SharepointFiles_Turner.ps1: -------------------------------------------------------------------------------- 1 | #Modify the URL For the site you are working with. 2 | 3 | connect-pnponline -url 4 | $today = (Get-Date) 5 | $restoreDate = $today.date.AddDays(-7) 6 | 7 | #Get list of items to be restored - 5000 item limit 8 | #Modify the DeletedByEmail Value After -eq and the DirName after -like 9 | Get-PnPRecycleBinItem | ? {($_.DeletedDate -gt $restoreDate) -and ($_.DeletedByEmail -eq 'rcurran@tcco.com') -and ($_.Dirname -like "General")} | select -last 4998 | Export-Csv c:\temp\restore.csv 10 | 11 | #restore items - 5000 item limit 12 | Get-PnPRecycleBinItem | ? {($_.DeletedDate -gt $restoreDate) -and ($_.DeletedByEmail -eq 'rcurran@tcco.com') -and ($_.Dirname -like "General")} | select -last 4998 | Restore-PnpRecyclebinItem -Force 13 | -------------------------------------------------------------------------------- /Report-GetAduserInformationSpecific.ps1: -------------------------------------------------------------------------------- 1 | #This Report is not working 2 | 3 | $Users=Import-Csv C:\csv\vm2.csv 4 | 5 | $logfile = "C:\csv\emailscriptlog-$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv" 6 | 7 | $csv = @() 8 | 9 | 10 | ForEach($user in $users){ 11 | 12 | $adInfo = Get-ADUser -Filter "Userprincipalname -eq '$($user.userprincipalname)'" -properties * 13 | 14 | $props = @{ 15 | 16 | "Name"=$adInfo.Name 17 | 18 | "Title"=$adInfo.Title 19 | 20 | "Manager" = [regex]::Match($adInfo.Manager,"CN=(\w+),.*").Captures.groups[1].value 21 | 22 | "Department"=$adInfo.Department 23 | 24 | } 25 | 26 | $obj = New-Object -TypeName psobject -Property $props 27 | 28 | $csv += $obj 29 | 30 | } 31 | 32 | $csv | Export-Csv -Path $logfile -Force -Append -NoTypeInformation -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace Percent_Change 17 | { 18 | /// 19 | /// Interaction logic for MainWindow.xaml 20 | /// 21 | public partial class MainWindow : Window 22 | { 23 | public MainWindow() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Bulk License Change.ps1: -------------------------------------------------------------------------------- 1 | 2 | 3 | $Option = Read-Host "1 For Exchange Archive License, 2 to remove the license" 4 | 5 | 6 | 7 | if($Option -eq "1"){ 8 | 9 | $Path = Read-Host "Enter bulk license CSV" 10 | 11 | $CSV = Import-CSV -Path "$Path" 12 | 13 | Write-Host "Path is $Path" 14 | 15 | $CSV | ForEach-Object { Set-Msoluserlicense -UserPrincipalName "$_.Email" -AddLicenses "ExcelsiorMedical:EXCHANGEARCHIVE" } 16 | Write-Host "Exchange Archive License has been assigned" 17 | Get-MsolAccountSku | Select AccountSkuID,ActiveUnits,ConsumedUnits 18 | 19 | } 20 | elseif($Option -eq "2"){ 21 | 22 | Set-MsolUserLicense -Userprincipalname "$_.Email" -RemoveLicenses "ExcelsiorMedical:EXCHANGEARCHIVE" 23 | 24 | } 25 | elseif($Option -ne "1" -or "2"){ 26 | 27 | Write-Host "No Licenses have been Assigned" 28 | } -------------------------------------------------------------------------------- /Export-ADGROUPMEMBERS.ps1: -------------------------------------------------------------------------------- 1 | 2 | Get-ADGroup -Filter * -PipelineVariable Group | Get-ADGroupMember -PipelineVariable Member | ForEach-Object { 3 | 4 | New-Object psobject -Property @{ 5 | Group = $group.Name 6 | 7 | "Group DN" = $Group.Name 8 | "Group SamAccountName" = $Group.SamAccountName 9 | "Member DN" = $Member.DistinguishedName 10 | "Member Name" = $Member.Name 11 | "Member SamAccountName" = $Member.SamAccountName 12 | } 13 | } #| Export-CSV C:\Powershell\Export1.csv -Append -NoTypeInformation 14 | 15 | <# 16 | $ADgroups = Get-ADgroup -Filter * 17 | 18 | foreach ($ADGroup in $ADgroups) { 19 | 20 | Get-AdgroupMember -Identity $Adgroup.DistinguishedName | Select * | Export-CSV C:\Powershell\Export.csv -Append 21 | 22 | } 23 | 24 | #> -------------------------------------------------------------------------------- /Test-Menu.ps1: -------------------------------------------------------------------------------- 1 | function Show-Menu 2 | { 3 | param ( 4 | 5 | [string]$Title = "My Menu" 6 | ) 7 | cls 8 | Write-Host "================ $Title ================" 9 | 10 | Write-Host "1: Press '1' for this option." 11 | Write-Host "2: Press '2' for this option." 12 | Write-Host "3: Press '3' for this option." 13 | Write-Host "Q: Press 'Q' to quit." 14 | } 15 | 16 | do 17 | { 18 | Show-Menu 19 | $input = Read-host "Please Make a Selection" 20 | switch($Input){ 21 | '1'{ 22 | cls 23 | 'You Chose Option #1' 24 | }'2'{ 25 | cls 26 | 'You Chose Option #2' 27 | }'3'{ 28 | cls 29 | 'You Chose Option #3' 30 | }'q'{ 31 | return 32 | } 33 | 34 | } 35 | pause 36 | } 37 | until ($input -eq 'q') 38 | -------------------------------------------------------------------------------- /Create-DistGroup.ps1: -------------------------------------------------------------------------------- 1 | $DisplayName = Read-Host "Enter the Distribution List Name" 2 | $Alias = Read-Host "Enter the Alias (One Word: I.E SHGAdmissions)" 3 | $PrimAddress = Read-Host "Enter the Primary SMTP Address (Email Address)" 4 | 5 | Write-Host "Creating Distribution List" 6 | 7 | New-DistributionGroup -Name "$DisplayName" -DisplayName "$DisplayName" -Alias "$Alias" -PrimarySmtpAddress $PrimAddress 8 | 9 | Write-Host "Distribution List Has Been Created" 10 | 11 | $Outside = Read-Host "Should this Distribution List Accept Senders outside of my Organization? Yes/No" 12 | 13 | If ($Outside -eq "Yes") { 14 | 15 | Set-DistributionGroup "$DistName" -RequireSenderAuthenticationEnabled $False 16 | 17 | } 18 | ElseIf ($Outside -eq "No"){ 19 | 20 | Set-DistributionGroup "$DistName" -RequireSenderAuthenticationEnabled $True 21 | 22 | } -------------------------------------------------------------------------------- /BulkAdd-DistGroup.ps1: -------------------------------------------------------------------------------- 1 | #Bulk Create Distribution Group 2 | 3 | $Path = Read-Host "Enter Bulk Distribution List CSV" 4 | 5 | Import-CSV -Path $Path | ForEach-Object { New-DistributionGroup -Name $_.Alias -DisplayName "$_.DisplayName" -Alias "$_.Alias" -PrimarySmtpAddress $_.PrimAddress | Add-DistributionGroupMember -Identity $_.PrimAddress -Member $_.Member | Set-DistributionGroup "$_.DisplayName" -RequireSenderAuthenticationEnabled $False } 6 | 7 | Write-Host "Distribution List Has Been Created" 8 | 9 | $Outside = Read-Host "Should this Distribution List Accept Senders outside of my Organization? Yes/No" 10 | 11 | #If ($Outside -eq "Yes") { 12 | 13 | #Set-DistributionGroup "$DisplayName" -RequireSenderAuthenticationEnabled $False 14 | 15 | #} 16 | #ElseIf ($Outside -eq "No"){ 17 | 18 | #Set-DistributionGroup "$DisplayName" -RequireSenderAuthenticationEnabled $True 19 | 20 | #} -------------------------------------------------------------------------------- /Add-BulkAdd-DistGroup.ps1: -------------------------------------------------------------------------------- 1 | #Bulk Create Distribution Group 2 | 3 | $Path = Read-Host "Enter Bulk Distribution List CSV" 4 | 5 | Import-CSV -Path $Path | ForEach-Object { New-DistributionGroup -Name $_.Alias -DisplayName "$_.DisplayName" -Alias "$_.Alias" -PrimarySmtpAddress $_.PrimAddress | Add-DistributionGroupMember -Identity $_.PrimAddress -Member $_.Member | Set-DistributionGroup "$_.DisplayName" -RequireSenderAuthenticationEnabled $False } 6 | 7 | Write-Host "Distribution List Has Been Created" 8 | 9 | $Outside = Read-Host "Should this Distribution List Accept Senders outside of my Organization? Yes/No" 10 | 11 | #If ($Outside -eq "Yes") { 12 | 13 | #Set-DistributionGroup "$DisplayName" -RequireSenderAuthenticationEnabled $False 14 | 15 | #} 16 | #ElseIf ($Outside -eq "No"){ 17 | 18 | #Set-DistributionGroup "$DisplayName" -RequireSenderAuthenticationEnabled $True 19 | 20 | #} -------------------------------------------------------------------------------- /Copy-Sharepoint-DocumentLibrary2.ps1: -------------------------------------------------------------------------------- 1 | #Config Variables 2 | $SiteURL = "https://tcco.sharepoint.com/sites/NJ-PrincetonUniversityJobs" 3 | $SourceLibraryURL = "Shared Documents/General/Chem Old Files" #Site Relative URL from the current site 4 | $TargetLibraryURL = "/sites/NJPrinceton/Archive/Chem Old Files" #Server Relative URL of the Target Folder 5 | 6 | #Connect to PnP Online 7 | Connect-PnPOnline -Url $SiteURL -Interactive 8 | 9 | #Get all Items from the Document Library 10 | $Items = Get-PnPFolderItem -FolderSiteRelativeUrl $SourceLibraryURL | Where {$_.Name -ne "Forms"} 11 | 12 | $Items 13 | 14 | #Move All Files and Folders Between Document Libraries 15 | Foreach($Item in $Items) 16 | { 17 | Move-PnPFile -SourceUrl $Item.ServerRelativeUrl -TargetUrl $TargetLibraryURL -AllowSchemaMismatch -Force -AllowSmallerVersionLimitOnDestination 18 | Write-host "Moved Item:"$Item.ServerRelativeUrl 19 | } -------------------------------------------------------------------------------- /Convert-UserDisplayNamesToSamAccount.ps1: -------------------------------------------------------------------------------- 1 | #This is for when you get a csv with displaynames vs the direct samaccountname. 2 | #It will search the user based on the displayname and spit out the Samaccountname which can be used as an identity for Add-AdGroupmember 3 | 4 | $users = Import-CSV C:\CSV\AplicareEmail.CSV 5 | 6 | $adGroup = read-host "Enter AD Group name" 7 | 8 | ForEach ($user in $users) { 9 | 10 | $samacc = Get-Aduser -Filter { displayName -like $($user.displayname)} | select samaccountname #| export-csv C:\CSV\AplicareEmailSamAccountName.csv -append -NoTypeInformation 11 | 12 | ForEach ($samaccs in $samacc) { 13 | Write-host "$($Samaccs.name) - $($Samaccs.Samaccountname) has been added to $adGroup" 14 | Add-ADGroupMember -Identity $adGroup -Members $($Samaccs.Samaccountname) 15 | 16 | } 17 | 18 | 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /Disable-EmailForwardingO365.ps1: -------------------------------------------------------------------------------- 1 | #Reference Change-BulkPW_Reset.ps1 for more details on a finished script. 2 | 3 | Function Get-FileName($InitialDirectory) 4 | { 5 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 6 | 7 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 8 | $OpenFileDialog.initialDirectory = $initialDirectory 9 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 10 | $OpenFileDialog.ShowDialog() | Out-Null 11 | $OpenFileDialog.FileName 12 | } 13 | 14 | $Path = Get-FileName 15 | 16 | $Users = Import-CSV $Path 17 | $i = 0 18 | ForEach ($user in $users) { 19 | 20 | Set-Mailbox -Identity $User.UserPrincipalName -ForwardingAddress $null -ForwardingSMTPAddress $Null -DeliverTomailboxandforward $False 21 | if ($i < 553){ 22 | $i++ 23 | Write-Host "#$i - "$user.DisplayName" is done" 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /Set-ACLAccess.ps1: -------------------------------------------------------------------------------- 1 | $Users = Get-Childitem -Path "\\USNJFS001\H$" | select Name 2 | #$Users = Import-csv C:\CSV\FileshareRemediation1.csv 3 | 4 | ForEach ($User in $users){ 5 | 6 | Try{ 7 | Write-host "Adding Domain Admins with Full Control to $($User.Name)" -ForegroundColor Yellow 8 | Add-ntfsaccess -Path "\\usnjfs001\H$\$($User.name)" -Account "Domain Admins" -AccessRights FullControl -ErrorAction Stop 9 | 10 | Write-Host "Adding Successful" -ForegroundColor Green 11 | 12 | "User Rights Are now below:" 13 | Get-NTFSaccess -Path "\\USNJFS001\H$\$($User.Name)" | Where ($_.Account -like "*Domain*" ) | Select "Account","AccessRights" 14 | 15 | }Catch{ 16 | Write-Host "$($User.name) Failed" -ForegroundColor Red 17 | $User | Select @{Name = "User Share"; Expression = {$($User.Name)}} | Export-CSV C:\CSV\FailedPermissions.csv -Append -NoTypeInformation 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /AD-TrustRelationshipFix.ps1: -------------------------------------------------------------------------------- 1 | #User input 2 | $Computer = Read-Host "Enter Computer name" 3 | $AdminAccount = Read-Host "Enter local Admin Account" 4 | $SecurePassword = Read-Host "Enter local Admin Password" -AsSecureString 5 | 6 | # Create Plain text password object and Credential Object 7 | $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword) 8 | $UnsecurePassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) 9 | $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AdminAccount, $SecurePassword 10 | 11 | #Enable PS Remoting 12 | .\psexec\Psexec.exe \\$Computer -u $AdminAccount -p $UnsecurePassword -h -d powershell.exe "enable-psremoting -force" 13 | 14 | # Repair secure Channel 15 | Write-Host "Resetting computer secure channel..." 16 | Invoke-Command -ComputerName $Computer -Credential $Credential -ScriptBlock { Test-ComputerSecureChannel -Repair } -------------------------------------------------------------------------------- /Change-Bulk License Change.ps1: -------------------------------------------------------------------------------- 1 | 2 | 3 | $Option = Read-Host "1 To Add Office License, 2 to remove the license" 4 | 5 | 6 | 7 | if($Option -eq "1"){ 8 | 9 | $Path = Read-Host "Enter bulk license CSV" 10 | 11 | $CSV = Import-CSV -Path "$Path" 12 | 13 | Write-Host "Path is $Path" 14 | 15 | $CSV | ForEach-Object { Set-Msoluserlicense -UserPrincipalName "$_.Email" -AddLicenses "ExcelsiorMedical:O365_BUSINESS" } 16 | Write-Host "Exchange Archive License has been assigned" 17 | Get-MsolAccountSku | Select AccountSkuID,ActiveUnits,ConsumedUnits 18 | 19 | } 20 | elseif($Option -eq "2"){ 21 | 22 | $Path = Read-Host "Enter bulk license CSV" 23 | 24 | $CSV = Import-CSV -Path "$Path" 25 | 26 | Write-Host "Path is $Path" 27 | 28 | Set-MsolUserLicense -Userprincipalname "$_.Email" -RemoveLicenses "ExcelsiorMedical:O365_BUSINESS" 29 | 30 | } 31 | elseif($Option -ne "1" -or "2"){ 32 | 33 | Write-Host "No Licenses have been Assigned" 34 | } -------------------------------------------------------------------------------- /Remove-MsoluserLicenses.ps1: -------------------------------------------------------------------------------- 1 | #Reference Change-BulkPW_Reset.ps1 for more details on a finished script. 2 | 3 | Function Get-FileName($InitialDirectory) 4 | { 5 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 6 | 7 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 8 | $OpenFileDialog.initialDirectory = $initialDirectory 9 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 10 | $OpenFileDialog.ShowDialog() | Out-Null 11 | $OpenFileDialog.FileName 12 | } 13 | 14 | $Path = Get-FileName 15 | 16 | $Users = Import-CSV $Path 17 | $i = 0 18 | ForEach ($user in $users) { 19 | 20 | Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -RemoveLicenses "EXCELSIORMEDICAL:EXCHANGESTANDARD" 21 | Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -RemoveLicenses "EXCELSIORMEDICAL:EXCHANGEDESKLESS" 22 | 23 | Write-Host ""$user.DisplayName" is done" 24 | 25 | } -------------------------------------------------------------------------------- /Development/IntuneTaskbarPins.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Intune/Intune-EnableAutomaticTimeZone.ps1: -------------------------------------------------------------------------------- 1 | # Enable system-wide location services 2 | Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location -Name Value -Value "Allow" 3 | 4 | # Set Time Zone Auto-Update Service to Automatic 5 | Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\tzautoupdate -Name start -Value "2" 6 | 7 | # Check if the Time Zone Auto-Update Service is running, and attempt to start it 8 | $serviceName = "tzautoupdate" 9 | $service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue 10 | 11 | if ($service.Status -ne "Running") { 12 | try { 13 | Start-Service -Name $serviceName 14 | Write-EventLog "Service '$serviceName' was not running and has been started." 15 | } catch { 16 | Write-EventLog "Failed to start service '$serviceName'. Error: $_" 17 | } 18 | } else { 19 | Write-EventLog "Service '$serviceName' is already running, no action." 20 | } 21 | -------------------------------------------------------------------------------- /Move-SBUsers.ps1: -------------------------------------------------------------------------------- 1 | # add pit nyn alb phi 2 | 3 | $OUs = @( 4 | 'OU=Users,OU=New Jersey,OU=North East,OU=Offices,DC=tcco,DC=org' 5 | 'OU=Users,OU=Albany,OU=North East,OU=Offices,DC=tcco,DC=org' 6 | 'OU=Users,OU=Buffalo,OU=North East,OU=Offices,DC=tcco,DC=org' 7 | 'OU=Users,OU=Philadelphia,OU=North Central,OU=Offices,DC=tcco,DC=org' 8 | 'OU=Users,OU=Pittsburgh,OU=North Central,OU=Offices,DC=tcco,DC=org' 9 | ) 10 | 11 | $Target = 'OU=Users,OU=Mahwah,OU=North East,OU=Offices,DC=tcco,DC=org' 12 | 13 | ForEach($OU in $OUs){ 14 | "Running for $OU" 15 | $SBUsers = Get-aduser -SearchBase $OU -Filter {streetaddress -like "*3 Paragon*"} 16 | "Found $($SBusers.count)" 17 | ForEach($SBUser in $SBUsers){ 18 | Move-ADObject -Identity $SBUser.DistinguishedName -TargetPath $Target 19 | Write-host "Moving $($SBuser.DisplayName) to $Target" -ForegroundColor Green 20 | } 21 | 22 | Write-host "Moved $($SBusers.count) Users from $OU" -ForegroundColor Green 23 | 24 | } -------------------------------------------------------------------------------- /Update-ADComputer_Description.ps1: -------------------------------------------------------------------------------- 1 | Function Get-FileName($InitialDirectory) 2 | { 3 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 4 | 5 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 6 | $OpenFileDialog.Dereferencelinks = $False 7 | $OpenFileDialog.initialDirectory = $initialDirectory 8 | #$OpenFileDialog.filter = "CSV (*.csv) | *.csv" 9 | $OpenFileDialog.ShowDialog() | Out-Null 10 | $OpenFileDialog.FileName 11 | } 12 | 13 | $i = 0 14 | 15 | Write-host "Select the List of Computers to Update" -ForegroundColor Green 16 | #Use Function to Get the CSV list of Computers 17 | $Comps = Get-FileName 18 | 19 | $PCS = Import-csv $Comps 20 | 21 | ForEach ($PC in $PCS){ 22 | 23 | $i++ 24 | 25 | #Show progress of the count 26 | Write-Progress -Activity "Updating Descriptions" -Status "Updating: $i of $($PCs.count)" 27 | Write-Host "Updating $($PC.Name)" 28 | 29 | Set-adcomputer -Identity $PC.Name -Description $PC.Description 30 | 31 | } -------------------------------------------------------------------------------- /Copy-Shortcut_To_PubDT_2.ps1: -------------------------------------------------------------------------------- 1 | $Comps = Import-csv "\\usnjfs001\shared\Ryan Curran\Scripts_Icons\Line comps.csv" 2 | 3 | ForEach($Comp in $Comps){ 4 | Try{ 5 | Write-host "Removing Vision System Assistance From $($Comp.name)" 6 | Remove-item -path "\\$($Comp.name)\C$\Users\Public\Desktop\Vision System Assistance.lnk" -ErrorAction Stop 7 | }Catch{ 8 | "$($Comp.name) Shortcut doesnt exist" 9 | } 10 | 11 | Try{ 12 | Write-host "Removing Vision System Assistance From $($Comp.name)" 13 | Remove-item -path "\\$($Comp.name)\C$\Users\Public\Desktop\Vision System Assistance.lnk" -ErrorAction Stop 14 | }Catch{ 15 | "$($Comp.name) Shortcut doesnt exist" 16 | } 17 | 18 | Try{ 19 | "Copying Vision System Assistance Shortcut to $($Comp.name)" 20 | xcopy "\\usnjfs001\shared\Ryan Curran\Scripts_Icons\medline icons\Vision System Assistance.lnk" "\\$($Comp.name)\C$\Users\Public\Desktop\" 21 | }Catch{ 22 | "$($Comp.Name) is Offline" 23 | } 24 | 25 | } 26 | 27 | pause -------------------------------------------------------------------------------- /Rename-BulkPhotos.ps1: -------------------------------------------------------------------------------- 1 | Function Get-FolderName($InitialDirectory) 2 | { 3 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 4 | 5 | $OpenFolderDialog = New-Object System.Windows.Forms.FolderBrowserDialog 6 | #$OpenFolderDialog.initialDirectory = $initialDirectory 7 | #$OpenFileDialog.filter = "CSV (*.csv) | *.csv" 8 | $OpenFolderDialog.ShowDialog() | Out-Null 9 | $OpenFolderDialog.SelectedPath 10 | } 11 | 12 | $Folder = Get-FolderName 13 | Write-Host "Warning: This will Overwrite any files with the same name/number in the directory you selected" -Foregroundcolor Red 14 | $JobName = Read-host "Enter a Prefix name for the pictures (Ex: NJBU)" 15 | 16 | 17 | $i = 0 18 | $Items = Get-Childitem -Path "$Folder" 19 | $Counts = Get-Childitem -path "$Folder" | Measure 20 | $Counts.count 21 | 22 | Foreach($Item in $Items){ 23 | $i++ 24 | rename-item -Path $Item.FullName -Newname "$($JobName)_$($i)" 25 | Write-Host "Renamed $($Item.name) to $($Jobname)_$($i)" -Foregroundcolor Green 26 | } 27 | -------------------------------------------------------------------------------- /Replace-ComputerDescription.ps1: -------------------------------------------------------------------------------- 1 | #This script would grab each computer from an OU Searchbase and Replace the symbol or text with what you entered in the description 2 | 3 | $OU = Read-Host "Please enter the OU that you want to work on (copy and paste it from AD, Example: OU=Computers,OU=City,OU=Region,OU=Offices,DC=DCName,DC=end" 4 | Write-host "You Selected OU - $OU" -ForegroundColor yellow -BackgroundColor green 5 | $Computers = Get-adcomputer -filter * -Searchbase "$OU" -properties Description | Select Name, Description 6 | $Symbol1 = Read-Host "Please Enter the text that you want to replace (What already exists in the description)" 7 | $Symbol2 = Read-Host "Please Enter the text that you want to be used as the replacement text" 8 | 9 | ForEach ($Comp in $Computers){ 10 | 11 | if($Comp.Description -ne $Null){ 12 | "$($Comp.Name): $($Comp.Description)" 13 | "Setting to: $($Comp.Description.Replace("$Symbol1","$Symbol2"))" 14 | 15 | Set-ADComputer -Identity $Comp.name -Description $Comp.Description.Replace("$Symbol1","$Symbol2") 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /Remove-BulkO365Licensing.ps1: -------------------------------------------------------------------------------- 1 | Write-Host "Select a CSV File for Importing" 2 | 3 | Function Get-Path 4 | { 5 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 6 | 7 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 8 | #$OpenFileDialog.initialDirectoiry = $initialDirectory 9 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 10 | $OpenFileDialog.ShowDialog() | Out-Null 11 | } 12 | 13 | $CSV = Get-Path 14 | 15 | $Option = Read-Host "1 To Remove User Licenses" 16 | 17 | if($Option -eq "1") { 18 | 19 | $CSV | % { Set-MsoluserLicense -UserPrincipalName $_.email -RemoveLicenses "EXCELSIORMEDICAL:VISIOCLIENT" , "EXCELSIORMEDICAL:PROJECTCLIENT" , "EXCELSIORMEDICAL:EXCHANGEDESKLESS" , "EXCELSIORMEDICAL:EXCHANGESTANDARD" , "EXCELSIORMEDICAL:OFFICESUBSCRIPTION" , "EXCELSIORMEDICAL:EXCHANGEARCHIVE" , "EXCELSIORMEDICAL:O365_BUSINESS" } | Out-File C:\CSV\Results.txt 20 | 21 | } 22 | 23 | elseif ($Option -ne "1"){ 24 | 25 | Write-Host "No Changes were Made, Be More Careful Next Time." 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Change-ActiveSyncEnabled Script.ps1: -------------------------------------------------------------------------------- 1 | #Change ActiveSyncEnabled Status 2 | 3 | Write-Output "Select CSV Path" 4 | 5 | Function Get-FileName 6 | { 7 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 8 | 9 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 10 | #$OpenFileDialog.initialDirectoiry = $initialDirectory 11 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv" 12 | $OpenFileDialog.ShowDialog() | Out-Null 13 | } 14 | 15 | $CSV = Get-Filename 16 | 17 | 18 | 19 | $Option = Read-Host "Press 1 to Set ActiveSyndEnabled to $True or Press 2 to set ActiveSyncEnabled to $False" 20 | 21 | if($Option -eq "1"){ 22 | 23 | $CSV | ForEach(Set-CASMailbox -Identity $_.UserPrincipalName -ActiveSyncEnabled $True) 24 | 25 | } 26 | 27 | elseif($Option -eq "2"){ 28 | 29 | $CSV | ForEach(Set-CASMailbox -Identity $_.UserPrincipalName -ActiveSyncEnabled $False) 30 | 31 | } 32 | 33 | 34 | 35 | elseif($option -ne "1" -or "2"){ 36 | 37 | Write-Host "Option 1 or 2 has not been chosen, no action has been taken" 38 | 39 | } -------------------------------------------------------------------------------- /Development/IntuneTaskbarPins2.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Archive/Restore-SharepointFiles_Turner_V4.ps1: -------------------------------------------------------------------------------- 1 | #Restore for Sharon Rowles 2 | 3 | Connect-Pnponline -url -interactive 4 | 5 | $restoredate = ((Get-Date).Date.AddDays(-0)) 6 | 7 | $RecycleBinitemsNL = Get-PnPRecycleBinItem | ? {($_.DeletedDate -gt $restoreDate) -and ($_.DeletedByEmail -like "*srowles@tcco.com*")} | select -last 4800 8 | $i = 0 9 | $loop = 1 10 | While($($RecycleBinitemsNL.count) -notlike "0"){ 11 | 12 | Foreach ($ID in $RecycleBinitemsNL){ 13 | 14 | Write-Progress -Activity "Restoring Files" -Status "Updating: $i of $($RecycleBinitemsNL.count) of Loop $Loop" 15 | "Restoring $($ID.Title)" 16 | 17 | Try{ 18 | Restore-PnPRecycleBinItem -Identity "$($ID.ID)"-force 19 | $i++ 20 | }Catch{ 21 | Write-host "$($ID.Title) Errored Out. This could be because the file already exists and will not overwrite." -ForegroundColor Red -BackgroundColor Black 22 | } 23 | } 24 | 25 | $RecycleBinitemsNL = Get-PnPRecycleBinItem | ? {($_.DeletedDate -gt $restoreDate) -and ($_.DeletedByEmail -like "*srowles@tcco.com*")} | select -last 4800 26 | $i=0 27 | $loop++ 28 | } 29 | -------------------------------------------------------------------------------- /Create-DistGroupandMember.ps1: -------------------------------------------------------------------------------- 1 | do { 2 | 3 | $DistName = Read-Host "Enter the Distribution List Name" 4 | $Alias = Read-Host "Enter the Alias (One Word: I.E SHGAdmissions)" 5 | $PrimAddress = Read-Host "Enter the Primary SMTP Address (Email Address)" 6 | 7 | Write-Host "Creating Distribution List" 8 | 9 | New-DistributionGroup -Name "$DistName" -DisplayName "$DistName" -Alias "$Alias" -PrimarySmtpAddress $PrimAddress 10 | 11 | Write-Host "Distribution List Has Been Created" 12 | 13 | $Outside = Read-Host "Should this Distribution List Accept Senders outside of my Organization? Yes/No" 14 | 15 | If ($Outside -eq "Yes") { 16 | 17 | Set-DistributionGroup "$DistName" -RequireSenderAuthenticationEnabled $False 18 | 19 | } 20 | ElseIf ($Outside -eq "No"){ 21 | 22 | Set-DistributionGroup "$DistName" -RequireSenderAuthenticationEnabled $True 23 | 24 | } 25 | 26 | $CSVPath = Write-Host "Please Paste the full path to the CSV file (Including the file itself)" 27 | 28 | Import-CSV "$CSVPath" | ForEach { Add-DistributionGroupMember -Identity "$DistName" -Members $_.members} 29 | 30 | Get-DistributionGroupMember -Identity "$DistName" 31 | 32 | $response = Read-Host "Repeat? (Y/N):" 33 | 34 | } 35 | 36 | while ($response -eq "y") -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29001.49 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Percent-Change", "Percent-Change\Percent-Change.csproj", "{A962D94B-9BD6-47B4-B5CB-51CAD026AAA2}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A962D94B-9BD6-47B4-B5CB-51CAD026AAA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {A962D94B-9BD6-47B4-B5CB-51CAD026AAA2}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {A962D94B-9BD6-47B4-B5CB-51CAD026AAA2}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {A962D94B-9BD6-47B4-B5CB-51CAD026AAA2}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {C82DE6FF-3ABD-4BBF-BFC0-520A06C5E5A6} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Development/Percent-Change/Percent-Change/Percent-Change/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Percent_Change.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /HowTo-AddSubvariables.ps1: -------------------------------------------------------------------------------- 1 | #Howto - Add Subvariables - Any of these would work 2 | 3 | # properties, via add-member (also supports methods, scripts, etc) 4 | $foo = new-object psobject 5 | $foo | add-member noteproperty name1 value1 6 | $foo | add-member noteproperty name2 value2 7 | 8 | 9 | # properties, via select-object or format-table 10 | $foo = new-object psobject | 11 | select @{Name="name1"; Expression={"value1"}}, 12 | @{Name="name2"; Expression={"value2"}} 13 | 14 | 15 | # hashtable, native syntax 16 | $foo = @{name1="value1" 17 | name2="value2"} 18 | 19 | 20 | # properties, via hashtable (v2.0 only) 21 | $foo = new-object psobject -Property @{ 22 | name1="value1" 23 | name2="value2" 24 | } 25 | 26 | 27 | # properties, via dynamic compilation (v2.0 only - also supports methods) 28 | add-type @' 29 | public class FooType 30 | { 31 | public string name1 = "value1"; 32 | public string name2 = "value2"; 33 | } 34 | '@ 35 | $foo = new-object FooType -------------------------------------------------------------------------------- /Archive/Restore-sharepointFiles_Turner_Simplified.ps1: -------------------------------------------------------------------------------- 1 | #Connect to Module 2 | $errorOccured = $False 3 | try { 4 | Get-installedmodule -name Microsoft.Online.Sharepoint.Powershell 5 | $errorOccured = $False 6 | } 7 | catch { 8 | Install-Module SharePointPnPPowerShellOnline 9 | $errorOccured = $True 10 | } 11 | if(!$errorOccured) { 12 | "Sharepoint Module Is Already Installed." 13 | } 14 | 15 | 16 | connect-pnponline -url -interactive 17 | $today = (Get-Date) 18 | $restoreDate = $today.date.AddDays(-0) 19 | 20 | $RecylceBinItems = Get-PnPRecycleBinItem | ? {($_.DeletedDate -gt $restoreDate) -and ($_.DeletedByEmail -like "**")} | select -last 4998 21 | $RecycleBinitemsNL = Get-PnPRecycleBinItem | ? {($_.DeletedDate -gt $restoreDate) -and ($_.DeletedByEmail -like "**")} 22 | 23 | #Get list of items to be restored - 5000 item limit 24 | $RecylceBinItems | Export-Csv c:\temp\restore.csv -NoTypeInformation 25 | 26 | 27 | 28 | #restore items - 5000 item limit 29 | $RecylceBinItems | Restore-PnpRecyclebinItem -Force 30 | 31 | 32 | 33 | 34 | #Get list of items to be restored - no document limit 35 | $RecylceBinItemsNL | Export-Csv c:\temp\restore.csv -NoTypeInformation 36 | 37 | 38 | 39 | # restore documents - no document limit 40 | $RecylceBinItemsNL | Restore-PnpRecyclebinItem -Force 41 | -------------------------------------------------------------------------------- /Report-Asset_To_User_4.ps1: -------------------------------------------------------------------------------- 1 | $Node = Import-csv C:\CSV\Test.csv 2 | 3 | $Collection = ForEach ($nodes in $node) { 4 | 5 | Write-host "Attempting to lookup" $Nodes.Hostname 6 | 7 | try { 8 | 9 | Test-Connection $($Nodes.Hostname) -Count 1 -ErrorAction Stop 10 | 11 | $UName = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_ComputerSystem | Select-Object UserName 12 | $HN = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_ComputerSystem | Select-Object PSComputerName 13 | $OS = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_OperatingSystem | Select-Object Caption 14 | 15 | $properties = @{ 16 | "UserName" = $($UName.Username) 17 | "Hostname" = $($HN.PSComputerName) 18 | "OS" = $($OS.Caption) 19 | } 20 | 21 | New-Object -Typename PSCustomObject -Property $properties 22 | } 23 | 24 | catch [System.Exception] { 25 | 26 | Write-host "$($nodes.hostname) has failed" 27 | 28 | $($nodes.hostname) | Export-csv C:\CSV\Error$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv -append -NoTypeInformation 29 | 30 | 31 | } 32 | 33 | } 34 | 35 | $collection | Export-csv C:\CSV\UserInfo$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv -NoTypeInformation -Append 36 | -------------------------------------------------------------------------------- /Report-ADGroupMembers_2019.ps1: -------------------------------------------------------------------------------- 1 | Function Get-FileName($InitialDirectory) 2 | { 3 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 4 | 5 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 6 | $OpenFileDialog.Dereferencelinks = $False 7 | $OpenFileDialog.initialDirectory = $initialDirectory 8 | #$OpenFileDialog.filter = "CSV (*.csv) | *.csv" 9 | $OpenFileDialog.ShowDialog() | Out-Null 10 | $OpenFileDialog.FileName 11 | } 12 | 13 | $RoleList = Get-FileName 14 | 15 | #$AllRoles = @() 16 | 17 | $RL = Import-csv $RoleList 18 | 19 | ForEach($User in $RL){ 20 | 21 | Get-Adgroupmember -Identity $User.Role | select @{Expression = {$User.Role}; Label = "Role"},Name,SamAccountName | Export-CSV C:\CSV\MemberCount-$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv -append -NoTypeinformation 22 | 23 | 24 | } 25 | 26 | <# 27 | 28 | $EndUsers = Get-AdgroupMember -Identity $($User.Role) | Select Name, SamAccountName 29 | 30 | $AllRoles += [pscustomobject]@{ 31 | 32 | "Role" = $User.Role 33 | "User" = $($EndUsers.Name) 34 | "Username" = $($Endusers.SamAccountName) 35 | 36 | 37 | } 38 | 39 | $AllRoles #| Export-CSV C:\CSV\MemberCount-$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv -append -NoTypeinformation 40 | #> -------------------------------------------------------------------------------- /Report-Asset_To_User_2.ps1: -------------------------------------------------------------------------------- 1 | $Node = Import-csv C:\CSV\Test.csv 2 | 3 | $Collection = ForEach ($nodes in $node) { 4 | 5 | Write-host "Attempting to lookup" $Nodes.Hostname 6 | 7 | try { 8 | 9 | Test-Connection $($Hns.Hostname) -quiet -Count 1 -ErrorAction Stop 10 | 11 | $UName = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_ComputerSystem | Select-Object UserName 12 | $HN = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_ComputerSystem | Select-Object PSComputerName 13 | $OS = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_OperatingSystem | Select-Object Caption 14 | 15 | $properties = @{ 16 | "UserName" = $($UName.Username) 17 | "Hostname" = $($HN.PSComputerName) 18 | "OS" = $($OS.Caption) 19 | "NotFound" = $null 20 | } 21 | 22 | New-Object -Typename PSCustomObject -Property $properties 23 | } 24 | 25 | catch [System.Exception] { 26 | 27 | Write-host "$($nodes.hostname) has failed" 28 | 29 | $($nodes.hostname) | Export-csv C:\CSV\Error$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv -append -NoTypeInformation 30 | 31 | 32 | } 33 | 34 | } 35 | 36 | $collection | Export-csv C:\CSV\UserInfo$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv -NoTypeInformation -Append 37 | -------------------------------------------------------------------------------- /Get-RemoteServicetag.ps1: -------------------------------------------------------------------------------- 1 | #Script for pulling service tags from computers 2 | 3 | 4 | 5 | 6 | Function PullSerial { 7 | 8 | Write-host "Please enter the IP address of the computer" -ForegroundColor Green 9 | 10 | $IP = Read-host "IP" 11 | 12 | 13 | $TC = Test-connection $IP -Quiet -Count 1 14 | 15 | if ($TC -eq $True){ 16 | 17 | Write-host "IP is live - Executing Remote Command" -ForegroundColor Green 18 | psexec -nobanner \\$IP powershell Get-Wmiobject -class win32_bios | Select PSComputername, Serialnumber 19 | 20 | }else{ 21 | Write-Host "$($IP) Test ping returned False" 22 | } 23 | 24 | $Title = Write-host "Do you need to search for more Service Tags / Serial Numbers?" -ForegroundColor Yellow -BackgroundColor Black 25 | $Prompt = "Enter your Choice" 26 | $Choices = [System.management.Automation.Host.ChoiceDescription[]] @("&Yes","&No") 27 | $Default = 1 28 | $Choice = $Host.UI.PromptForChoice($Title, $Prompt, $Choices, $Default) 29 | 30 | #Action based on the choice number in switch format 31 | switch($Choice) 32 | { 33 | 34 | 0 { $Type = "Yes" 35 | PullSerial 36 | } 37 | 1 { $Type = "No" 38 | Exit 39 | } 40 | } 41 | } 42 | 43 | PullSerial 44 | -------------------------------------------------------------------------------- /Delete-ADComputer.ps1: -------------------------------------------------------------------------------- 1 | Import-module activedirectory 2 | 3 | Set-location AD: 4 | 5 | 6 | #Write an "Are you sure" option. 7 | 8 | 9 | 10 | #assign Get-location to the variable $local 11 | $local = Get-Location 12 | 13 | 14 | #While the path of local is not equal to AD:\ go up a directory and update the location for variable $local 15 | 16 | 17 | $HN = Import-csv C:\CSV\DeletefromAD.csv 18 | 19 | $HN 20 | 21 | $Choice = Read-Host "Are you Sure you want to Delete these? " 22 | 23 | 24 | if($Choice -eq "Yes" -or "Y" -or "1"){ 25 | while($local.path -ne "AD:\"){ 26 | 27 | cd .. 28 | 29 | $local = Get-Location 30 | $local.path 31 | } 32 | 33 | Set-location "OU=US_Excelsior_Medical_Neptune_NJ,OU=Users_And_Computers,DC=medline,DC=com" 34 | 35 | ForEach ($HNs in $HN){ 36 | 37 | $tc = test-connection $Hns.Hostname -quiet -count 1 38 | 39 | if($tc -eq $False){ 40 | 41 | 42 | Try{ 43 | 44 | Remove-Adcomputer -Identity $HNs.Hostname -ErrorAction Stop 45 | 46 | } 47 | 48 | catch [System.Exception] { 49 | 50 | Write-host "$($HNs.Hostname) Doesn't exist" 51 | 52 | } 53 | 54 | } 55 | 56 | 57 | } 58 | 59 | 60 | }else{ 61 | 62 | "Aborted" 63 | 64 | } 65 | 66 | Push-location C:\Powershell-Repository 67 | -------------------------------------------------------------------------------- /Development/TestDirectoryCreation.ps1: -------------------------------------------------------------------------------- 1 | $udrivelist = Get-Childitem -Path "\\usnjfs001\H$" -exclude _archive,Batch,Kioware$ 2 | 3 | #Establish count variable 4 | $i = 0 5 | 6 | #establish parameters for cimsession 7 | $Computername = 'usnjfs001' 8 | $fullaccess = 'everyone' 9 | $Session = New-CimSession -Computername $Computername 10 | 11 | ForEach($UDL in $Udrivelist){ 12 | 13 | $ACL = Get-NTFSaccess -Path "\\USNJFS001\H$\$($UDL.name)" 14 | 15 | New-Item -Path "\\usnjfs001\H$\_Archive\Test\$($UDL.Name)" -ItemType Directory 16 | 17 | ForEach($ACLUser in $ACL){ 18 | #ACLUser.Access and ACLUser.PSChildname 19 | Write-host "Adding $($ACLUser.AccessRights) for $ACLUser to " 20 | $ACLUser 21 | #Set-Acl "C:\Testing\$($UDL.Name)" -AclObject $ACL 22 | 23 | 24 | } 25 | 26 | } 27 | 28 | 29 | <# $udrivelist = Get-Childitem -Path "\\usnjfs001\H$" -exclude _archive,Batch,Kioware$ 30 | 31 | 32 | ForEach($UDL in $Udrivelist){ 33 | $NTFS = Get-NTFSAccess -Path "\\USNJFS001\H$\$($UDL.name)" 34 | 35 | New-Item -Path "C:\Testing\$($UDL.Name)" -ItemType Directory 36 | 37 | ForEach($NTFSPerm in $NTFS){ 38 | "Trying to add $($NTFSPerm.Account.Accountname) to $($UDL.name)" 39 | Add-NTFSACCESS -Path "C:\Testing\$($UDL.Name)" -AccessRights $NTFS.AccessRights -Account $NTFSPerm.Account.AccountName 40 | 41 | 42 | } 43 | 44 | } #> -------------------------------------------------------------------------------- /Remove-Licenses-CSV.ps1: -------------------------------------------------------------------------------- 1 | Write-Host "This will Remove All Licenses For Users Provided VIA CSV" 2 | $CSVPath = Read-Host "Please Paste the full path to the CSV file (Including the file itself)" 3 | 4 | 5 | $Option = Read-Host "1 To Remove User Licenses" 6 | 7 | if($Option -eq "1"){ 8 | 9 | Import-CSV $CSVPath | foreach-Object { Set-MsolUserLicense -UserPrincipalName $_.email -RemoveLicenses "EXCELSIORMEDICAL:VISIOCLIENT" } 10 | Import-CSV $CSVPath | foreach-Object { Set-MsolUserLicense -UserPrincipalName $_.email -RemoveLicenses "EXCELSIORMEDICAL:PROJECTCLIENT" } 11 | Import-CSV $CSVPath | foreach-Object { Set-MsolUserLicense -UserPrincipalName $_.email -RemoveLicenses "EXCELSIORMEDICAL:EXCHANGEDESKLESS" } 12 | Import-CSV $CSVPath | foreach-Object { Set-MsolUserLicense -UserPrincipalName $_.email -RemoveLicenses "EXCELSIORMEDICAL:EXCHANGESTANDARD" } 13 | Import-CSV $CSVPath | foreach-Object { Set-MsolUserLicense -UserPrincipalName $_.email -RemoveLicenses "EXCELSIORMEDICAL:OFFICESUBSCRIPTION" } 14 | Import-CSV $CSVPath | foreach-Object { Set-MsolUserLicense -UserPrincipalName $_.email -RemoveLicenses "EXCELSIORMEDICAL:EXCHANGEARCHIVE" } 15 | Import-CSV $CSVPath | foreach-Object { Set-MsolUserLicense -UserPrincipalName $_.email -RemoveLicenses "EXCELSIORMEDICAL:O365_BUSINESS" } 16 | 17 | } 18 | 19 | elseif($Option -ne "1"){ 20 | 21 | Write-Host "No Changes Were Made, Be More Careful Next Time." 22 | 23 | } -------------------------------------------------------------------------------- /pythongui.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | import subprocess 3 | 4 | def start_service(): 5 | subprocess.run(["service", "start", service_name.get()], capture_output=True) 6 | log.insert("end", f"Started service {service_name.get()}\n") 7 | 8 | def stop_service(): 9 | subprocess.run(["service", "stop", service_name.get()], capture_output=True) 10 | log.insert("end", f"Stopped service {service_name.get()}\n") 11 | 12 | def restart_service(): 13 | subprocess.run(["service", "restart", service_name.get()], capture_output=True) 14 | log.insert("end", f"Restarted service {service_name.get()}\n") 15 | 16 | root = tk.Tk() 17 | root.title("Service Manager") 18 | 19 | service_name = tk.StringVar() 20 | 21 | service_entry = tk.Entry(root, textvariable=service_name) 22 | service_entry.pack() 23 | 24 | start_button = tk.Button(root, text="Start", command=start_service) 25 | start_button.pack() 26 | 27 | stop_button = tk.Button(root, text="Stop", command=stop_service) 28 | stop_button.pack() 29 | 30 | restart_button = tk.Button(root, text="Restart", command=restart_service) 31 | restart_button.pack() 32 | 33 | log = tk.Text(root) 34 | log.pack() 35 | 36 | root.mainloop() 37 | 38 | #The main difference from the previous example is that the capture_output argument is set to True in the subprocess.run function to capture the standard output 39 | # of the commands. Also, the "end" argument is used instead of tk.END to specify the end of the text box in the log.insert method. -------------------------------------------------------------------------------- /Report-Asset_To_User_v5.ps1: -------------------------------------------------------------------------------- 1 | $Node = Import-csv C:\CSV\Test.csv 2 | 3 | $Collection = ForEach ($nodes in $node) { 4 | 5 | Write-host "Attempting to lookup" $Nodes.Hostname 6 | 7 | try { 8 | 9 | $pt = Test-Connection $($Nodes.Hostname) -Quiet -Count 1 10 | 11 | if ($pt -eq $false) {error} 12 | 13 | $UName = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_ComputerSystem | Select-Object UserName 14 | $HN = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_ComputerSystem | Select-Object PSComputerName 15 | $OS = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_OperatingSystem | Select-Object Caption 16 | 17 | $properties = @{ 18 | "UserName" = $($UName.Username) 19 | "Hostname" = $($HN.PSComputerName) 20 | "OS" = $($OS.Caption) 21 | 22 | } 23 | 24 | New-Object -Typename PSCustomObject -Property $properties 25 | } 26 | 27 | Catch [System.Management.Automation.CommandNotFoundException] { 28 | 29 | Write-host "$($nodes.hostname) has failed" 30 | "$open" 31 | 32 | $($nodes.Hostname) | Add-Content C:\CSV\Error.log 33 | 34 | } 35 | } 36 | 37 | $collection | Export-csv C:\CSV\UserInfo$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv -NoTypeInformation -Append 38 | 39 | Get-Content C:\CSV\Error.log | Add-Content C:\CSV\Error$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv 40 | 41 | Remove-Item C:\CSV\Error.log 42 | -------------------------------------------------------------------------------- /Report-MDMEnrollmentV2.ps1: -------------------------------------------------------------------------------- 1 | $results = @() 2 | $pattern = "\((.*?)\)" 3 | $users = Get-ADUser -Properties memberof, displayname, office, Manager -Filter {Enabled -eq $True} 4 | foreach ($user in $users) { 5 | $groups = $user.memberof -join ';' 6 | $match = [regex]::Match($User.DisplayName,$pattern) 7 | $results += New-Object psObject -Property @{ 8 | 'User'=$user.name 9 | 'DisplayName'=$user.DisplayName 10 | 'Office'=$user.office 11 | 'Groups'= $groups 12 | 'Manager'=$user.Manager 13 | 'UserPrincipalname'=$user.UserPrincipalname 14 | 'BU'= $match.Groups[1].Value 15 | } 16 | } 17 | $results | Where-Object { $_.groups -notmatch 'TUR.ALL.MDM.USERS' -and $_.Manager -ne $null} | Select-Object user, displayname, UserprincipalName, BU,Office | Export-excel "C:\Users\rcurran\Turner Construction\IS Field Staff - PANJ and NYN\Regional Projects\MDM\TUR.ALL.MDM.Users-Enrollment-$([DateTime]::Now.ToSTring("MM-dd-yyyy")).xlsx" -Autosize -Autofilter -WorksheetName "Not Enrolled" 18 | $results | Where-Object { $_.groups -match 'TUR.ALL.MDM.USERS' -and $_.Manager -ne $null} | Select-Object user, displayname, UserprincipalName, BU,Office | Export-excel "C:\Users\rcurran\Turner Construction\IS Field Staff - PANJ and NYN\Regional Projects\MDM\TUR.ALL.MDM.Users-Enrollment-$([DateTime]::Now.ToSTring("MM-dd-yyyy")).xlsx" -Autosize -Autofilter -WorksheetName "Enrolled" 19 | 20 | 21 | 22 | #'BU'=$user.DisplayName.Substring($user.Displayname.IndexOf("(")+1,$User.Displayname.IndexOf(")")-$User.DisplayName.IndexOf("(")-1) -------------------------------------------------------------------------------- /Report-Asset_To_User_3.ps1: -------------------------------------------------------------------------------- 1 | $Node = Import-csv C:\CSV\Test.csv 2 | 3 | $Collection = ForEach ($nodes in $node) { 4 | 5 | Write-host "Attempting to lookup" $Nodes.Hostname 6 | 7 | try { 8 | $UName = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_ComputerSystem -ErrorAction Stop | Select-Object UserName 9 | $HN = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_ComputerSystem -ErrorAction Stop | Select-Object PSComputerName 10 | $OS = Get-Wmiobject -Computername $Nodes.Hostname -Class Win32_OperatingSystem -ErrorAction Stop | Select-Object Caption 11 | 12 | $properties = @{ 13 | "UserName" = $($UName.Username) 14 | "Hostname" = $($HN.PSComputerName) 15 | "OS" = $($OS.Caption) 16 | "NotFound" = $null 17 | } 18 | 19 | New-Object -Typename PSCustomObject -Property $properties 20 | } 21 | 22 | Catch [System.Exception] { 23 | #$RH = $Nodes 24 | $Nodes 25 | #$RH = $($RH.Hostname) #-replace ‘[@{}]’ 26 | Add-Content -Path 'C:\CSV\AppLog.log' -Value "failed to lookup $($Nodes.Hostname)" 27 | 28 | } 29 | 30 | catch { 31 | $properties = @{ 32 | "Username" = $null 33 | "Hostname" = $null 34 | "OS" = $null 35 | "NotFound" = $($nodes.Hostname) 36 | 37 | } 38 | 39 | 40 | 41 | New-Object -TypeName PSObject -Property $properties 42 | 43 | } 44 | 45 | } 46 | 47 | $collection | Export-csv C:\CSV\UserInfo$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv -NoTypeInformation -Append -------------------------------------------------------------------------------- /Intune/Intune-EnableAutomaticTimeZone-Logging.ps1: -------------------------------------------------------------------------------- 1 | # Enable system-wide location services 2 | Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location -Name Value -Value "Allow" 3 | 4 | # Set Time Zone Auto-Update Service to Automatic 5 | Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\tzautoupdate -Name start -Value "2" 6 | 7 | # Define the service name and event log source 8 | $serviceName = "tzautoupdate" 9 | $eventSource = "CustomScriptLog" 10 | $eventLogName = "Application" 11 | 12 | # Ensure the event source exists 13 | if (-not (Get-EventLog -LogName $eventLogName -Source $eventSource -ErrorAction SilentlyContinue)) { 14 | New-EventLog -LogName $eventLogName -Source $eventSource 15 | } 16 | 17 | # Check if the Time Zone Auto-Update Service is running, and attempt to start it 18 | $service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue 19 | 20 | if ($service.Status -ne "Running") { 21 | try { 22 | Start-Service -Name $serviceName 23 | Write-EventLog -LogName $eventLogName -Source $eventSource -EventId 1001 -EntryType Information -Message "Service '$serviceName' was not running and has been started successfully." 24 | } catch { 25 | Write-EventLog -LogName $eventLogName -Source $eventSource -EventId 1002 -EntryType Error -Message "Failed to start service '$serviceName'. Error: $_" 26 | } 27 | } else { 28 | Write-EventLog -LogName $eventLogName -Source $eventSource -EventId 1003 -EntryType Information -Message "Service '$serviceName' is already running. No action was necessary." 29 | } 30 | -------------------------------------------------------------------------------- /Development/Parameter test.ps1: -------------------------------------------------------------------------------- 1 | #Parameters 2 | $SiteURL = "https://tcco.sharepoint.com/sites/CFCPayrollDepartment" 3 | $ListName = "Trade Payroll - Retrieve from CFC" 4 | $CSVFile = "C:\Temp\FolderStats.csv" 5 | 6 | #Connect to SharePoint Online 7 | Connect-PnPOnline $SiteURL -Interactive 8 | 9 | #Get the list 10 | $List = Get-PnPList -Identity $ListName 11 | 12 | #Get Folders from the Library - with progress bar 13 | $global:counter = 0 14 | $FolderItems = Get-PnPListItem -List $ListName -PageSize 5000 -Fields FileLeafRef -ScriptBlock { Param($items) $global:counter += $items.Count; Write-Progress -PercentComplete ` 15 | ($global:Counter / ($List.ItemCount) * 100) -Activity "Getting Items from List:" -Status "Processing Items $global:Counter to $($List.ItemCount)";} #| Where {$_.FileSystemObjectType -eq "Folder"} 16 | Write-Progress -Activity "Completed Retrieving Folders from List $ListName" -Completed 17 | 18 | $FolderStats = @() 19 | #Get Files and Subfolders count on each folder in the library 20 | ForEach($FolderItem in $FolderItems) 21 | { 22 | #Get Files and Folders of the Folder 23 | Get-PnPProperty -ClientObject $FolderItem.Folder -Property Files, Folders 24 | 25 | #Collect data 26 | $Data = [PSCustomObject][ordered]@{ 27 | FolderName = $FolderItem.FieldValues.FileLeafRef 28 | URL = $FolderItem.FieldValues.FileRef 29 | FilesCount = $FolderItem.Folder.Files.Count 30 | SubFolderCount = $FolderItem.Folder.Folders.Count 31 | } 32 | $Data 33 | #$FolderStats+= $Data 34 | } 35 | #Export the data to CSV 36 | $FolderStats | Export-Csv -Path $CSVFile -NoTypeInformation -------------------------------------------------------------------------------- /Template_form.ps1: -------------------------------------------------------------------------------- 1 | Add-Type -AssemblyName System.Windows.Forms 2 | Add-Type -AssemblyName System.Drawing 3 | 4 | $Form = New-Object System.Windows.Forms.Form 5 | $Form.Text = 'Restore Sharepoint Files' 6 | $Form.Size = New-Object System.Drawing.Size(400,300) 7 | $Form.StartPosition = 'CenterScreen' 8 | $okb = New-Object System.Windows.Forms.Button 9 | $okb.Location = New-Object System.Drawing.Point(40,130) 10 | $okb.Size = New-Object System.Drawing.Size(75,25) 11 | $okb.Text = 'Submit' 12 | $okb.DialogResult = [System.Windows.Forms.DialogResult]::OK 13 | $Form.AcceptButton = $okb 14 | $Form.Controls.Add($okb) 15 | $Form.CancelButton = $cb 16 | $Form.Controls.Add($cb) 17 | $CancelB = New-Object System.Windows.Forms.Button 18 | $CancelB.Location = New-Object System.Drawing.Point(85,130) 19 | $CancelB.Size = New-Object System.Drawing.Size(75,25) 20 | $CancelB.Text = 'close' 21 | $CancelB.DialogResult = [System.Windows.Forms.DialogResult]::Cancel 22 | $Form.AcceptButton = $CancelB 23 | $Form.Controls.Add($CancelB) 24 | $lb = New-Object System.Windows.Forms.Label 25 | $lb.Location = New-Object System.Drawing.Point(40,40) 26 | $lb.Size = New-Object System.Drawing.Size(240,40) 27 | $lb.Text = 'Please enter the URL of the site. Example: https://tcco.sharepoint.com/sites/SiteName' 28 | $Form.Controls.Add($lb) 29 | $tb = New-Object System.Windows.Forms.TextBox 30 | $tb.Location = New-Object System.Drawing.Point(40,80) 31 | $tb.Size = New-Object System.Drawing.Size(240,20) 32 | $Form.Controls.Add($tb) 33 | $Form.Topmost = $true 34 | $Form.Add_Shown({$tb.Select()}) 35 | $rs = $Form.ShowDialog() 36 | if ($rs -eq [System.Windows.Forms.DialogResult]::OK) 37 | { 38 | $y = $tb.Text 39 | Write-Host "Entered text is" -ForegroundColor Green 40 | $y 41 | } -------------------------------------------------------------------------------- /Update-ADUserTitle.ps1: -------------------------------------------------------------------------------- 1 | #This script would grab each user from an OU Searchbase and check the Title against the description, if the Title is different (which is correct) 2 | #It will take the Title and replace the description, this is for BU's that use the Description field as a replacement for Title. 3 | Import-module activedirectory 4 | $OU = Read-Host "Please enter the OU that you want to work on" 5 | Write-host "You Selected OU - $OU" -ForegroundColor yellow -BackgroundColor Darkgreen 6 | # $Users = Get-aduser -filter * -Searchbase "$OU" -properties Title, Description | Select Name, Samaccountname, Description, Title, Enabled | Where-object {$_.Enabled -eq $True} 7 | $users = Get-aduser -Searchbase "$OU" -Filter {Description -notlike "*JV*"} -Properties Description, title 8 | 9 | $countChange = 0 10 | $countSame = 0 11 | 12 | Foreach ($User in $Users){ 13 | 14 | if(($($User.Description) -ne ($User.Title)) -and ($User.Title) -ne $Null){ 15 | 16 | Write-Host "Updating $($User.Name) from $($User.Description) to $($User.Title). `n" -ForegroundColor Green 17 | Set-aduser -identity "$($User.SamAccountName)" -Description $($User.Title) #-whatif 18 | $countChange++ 19 | 20 | }else { 21 | 22 | Write-Host "$($User.Name)'s description $($User.Description) is accurate to their title $($User.Title), No changes have been made. `n" -ForegroundColor Yellow 23 | $countSame++ 24 | 25 | } 26 | } 27 | 28 | Write-host "===" -ForegroundColor Red 29 | Write-host "Out of a total of $($Users.count) processed employees in $OU `n 30 | $countChange employee titles updated `n 31 | $countSame employee titles that went unchanged." -ForegroundColor Green 32 | Write-Host "===" -ForegroundColor Red -------------------------------------------------------------------------------- /testform.ps1: -------------------------------------------------------------------------------- 1 | 2 | $Form = New-Object System.Windows.Forms.Form 3 | $Form.Text = 'Restore Sharepoint Files' 4 | $Form.Size = New-Object System.Drawing.Size(400,300) 5 | $Form.StartPosition = 'CenterScreen' 6 | $okb = New-Object System.Windows.Forms.Button 7 | $okb.Location = New-Object System.Drawing.Point(40,130) 8 | $okb.Size = New-Object System.Drawing.Size(75,25) 9 | $okb.Text = 'Submit' 10 | $okb.DialogResult = [System.Windows.Forms.DialogResult]::OK 11 | $Form.AcceptButton = $okb 12 | $Form.Controls.Add($okb) 13 | $Form.CancelButton = $cb 14 | $Form.Controls.Add($cb) 15 | $CancelB = New-Object System.Windows.Forms.Button 16 | $CancelB.Location = New-Object System.Drawing.Point(200,130) 17 | $CancelB.Size = New-Object System.Drawing.Size(75,25) 18 | $CancelB.Text = 'close' 19 | $CancelB.DialogResult = [System.Windows.Forms.DialogResult]::Cancel 20 | $Form.AcceptButton = $CancelB 21 | $Form.Controls.Add($CancelB) 22 | $lb = New-Object System.Windows.Forms.Label 23 | $lb.Location = New-Object System.Drawing.Point(40,40) 24 | $lb.Size = New-Object System.Drawing.Size(240,40) 25 | $lb.Text = "$($Question)" 26 | $Form.Controls.Add($lb) 27 | $tb = New-Object System.Windows.Forms.TextBox 28 | $tb.Location = New-Object System.Drawing.Point(40,80) 29 | $tb.Size = New-Object System.Drawing.Size(240,20) 30 | $Form.Controls.Add($tb) 31 | $Form.Topmost = $true 32 | $Form.Add_Shown({$tb.Select()}) 33 | $rs = $Form.ShowDialog() 34 | 35 | if ($rs -eq [System.Windows.Forms.DialogResult]::OK){ 36 | $y = $tb.Text 37 | Write-Host "Entered text is" -ForegroundColor Green 38 | $y 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Report-ProductKey.ps1: -------------------------------------------------------------------------------- 1 | function Get-WindowsKey { 2 | ## function to retrieve the Windows Product Key from any PC 3 | ## by Jakob Bindslet (jakob@bindslet.dk) 4 | param ($targets = ".") 5 | $hklm = 2147483650 6 | $regPath = "Software\Microsoft\Windows NT\CurrentVersion" 7 | $regValue = "DigitalProductId" 8 | Foreach ($target in $targets) { 9 | $productKey = $null 10 | $win32os = $null 11 | $wmi = [WMIClass]"\\$target\root\default:stdRegProv" 12 | $data = $wmi.GetBinaryValue($hklm,$regPath,$regValue) 13 | $binArray = ($data.uValue)[52..66] 14 | $charsArray = "B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9" 15 | ## decrypt base24 encoded binary data 16 | For ($i = 24; $i -ge 0; $i--) { 17 | $k = 0 18 | For ($j = 14; $j -ge 0; $j--) { 19 | $k = $k * 256 -bxor $binArray[$j] 20 | $binArray[$j] = [math]::truncate($k / 24) 21 | $k = $k % 24 22 | } 23 | $productKey = $charsArray[$k] + $productKey 24 | If (($i % 5 -eq 0) -and ($i -ne 0)) { 25 | $productKey = "-" + $productKey 26 | } 27 | } 28 | $win32os = Get-WmiObject Win32_OperatingSystem -computer $target 29 | $obj = New-Object Object 30 | $obj | Add-Member Noteproperty Computer -value $target 31 | $obj | Add-Member Noteproperty Caption -value $win32os.Caption 32 | $obj | Add-Member Noteproperty CSDVersion -value $win32os.CSDVersion 33 | $obj | Add-Member Noteproperty OSArch -value $win32os.OSArchitecture 34 | $obj | Add-Member Noteproperty BuildNumber -value $win32os.BuildNumber 35 | $obj | Add-Member Noteproperty RegisteredTo -value $win32os.RegisteredUser 36 | $obj | Add-Member Noteproperty ProductID -value $win32os.SerialNumber 37 | $obj | Add-Member Noteproperty ProductKey -value $productkey 38 | $obj 39 | } 40 | } -------------------------------------------------------------------------------- /Intune/Intune-WindowsHelloRemediationCheck.ps1: -------------------------------------------------------------------------------- 1 | # Define registry paths to check 2 | $registryPaths = @( 3 | @{ Path = "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\Settings\AllowSignInOptions"; Name = "value"; ExpectedValue = 0 }, 4 | @{ Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System"; Name = "AllowDomainPINLogon"; ExpectedValue = 0 }, 5 | @{ Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"; Name = "AllowDomainPINLogon"; ExpectedValue = 0 } 6 | ) 7 | 8 | $biometricPaths = @( 9 | @{ Path = "HKLM:\SOFTWARE\Policies\Microsoft\Biometrics"; Name = "Enabled"; ExpectedValue = 0 }, 10 | @{ Path = "HKLM:\SOFTWARE\Policies\Microsoft\Biometrics\FacialFeatures"; Name = "Enabled"; ExpectedValue = 0 }, 11 | @{ Path = "HKLM:\SOFTWARE\Policies\Microsoft\Biometrics\Fingerprint"; Name = "Enabled"; ExpectedValue = 0 } 12 | ) 13 | 14 | $remediationNeeded = $false 15 | 16 | # Check registry settings 17 | foreach ($reg in ($registryPaths + $biometricPaths)) { 18 | if (Test-Path $reg.Path) { 19 | $currentValue = (Get-ItemProperty -Path $reg.Path -Name $reg.Name -ErrorAction SilentlyContinue).$($reg.Name) 20 | if ($currentValue -ne $reg.ExpectedValue) { 21 | $remediationNeeded = $true 22 | } 23 | } else { 24 | $remediationNeeded = $true 25 | } 26 | } 27 | 28 | # Check if Windows Hello PIN folder still exists 29 | $ngcFolderPath = "C:\Windows\ServiceProfiles\LocalService\AppData\Local\Microsoft\NGC" 30 | if (Test-Path $ngcFolderPath) { 31 | $remediationNeeded = $true 32 | } 33 | 34 | # Exit codes for Intune Remediation 35 | if ($remediationNeeded) { 36 | Write-Host "Windows Hello for Business settings are incorrect. Remediation required." 37 | exit 1 38 | } else { 39 | ` 40 | } 41 | -------------------------------------------------------------------------------- /Copy-Shortcut_To_PubDT.ps1: -------------------------------------------------------------------------------- 1 | #Reference Change-BulkPW_Reset.ps1 for more details on a finished script. 2 | 3 | Function Get-FileName($InitialDirectory) 4 | { 5 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 6 | 7 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog 8 | $OpenFileDialog.Dereferencelinks = $False 9 | $OpenFileDialog.initialDirectory = $initialDirectory 10 | #$OpenFileDialog.filter = "CSV (*.csv) | *.csv" 11 | $OpenFileDialog.ShowDialog() | Out-Null 12 | $OpenFileDialog.FileName 13 | } 14 | Function Get-FolderName($InitialDirectory) 15 | { 16 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 17 | 18 | $OpenFolderDialog = New-Object System.Windows.Forms.FolderBrowserDialog 19 | #$OpenFolderDialog.initialDirectory = $initialDirectory 20 | #$OpenFileDialog.filter = "CSV (*.csv) | *.csv" 21 | $OpenFolderDialog.ShowDialog() | Out-Null 22 | $OpenFolderDialog.SelectedPath 23 | } 24 | 25 | 26 | Write-Host "Select the Shortcut to Transfer" 27 | $Shortcut = Get-FileName 28 | 29 | Write-host "Select the List of Computers to transfer the shortcut to" 30 | $Comps = Get-FileName 31 | 32 | $SC = $Shortcut 33 | $PCS = Import-CSV $Comps 34 | $i = 0 35 | 36 | 37 | ForEach ($PC in $PCS){ 38 | #Increment $i from 0 to get a count 39 | $i++ 40 | #Show progress of the count 41 | Write-Progress -Activity "Copying $SC" -Status "Copied: $i of $($PCs.count)" 42 | 43 | Write-host "Copying to $($PC.Hostname)" 44 | xcopy $SC "\\$($PC.Hostname)\C$\Users\Public\Desktop" /y 45 | 46 | } 47 | 48 | <# ForEach($PC in $PCs){ 49 | Write-Host "Copying to $($PC.Hostname)" 50 | xcopy $SC "\\$($PC.Hostname)\C$\ProgramData\Microsoft\Windows\Start Menu\" 51 | 52 | } #> 53 | -------------------------------------------------------------------------------- /Set-ADUserAddressByOU.ps1: -------------------------------------------------------------------------------- 1 | #This Script will update the address based on the user captured data for the OU that is selected. 2 | 3 | Import-module activedirectory 4 | Write-Host "This script will set the address for all users within the OU you select, please answer the questions below exactly as that will be how it is entered into Active Directory`n" 5 | $OU = Read-Host "Please enter the OU that you want to work on" 6 | $Address = Read-Host "Please enter the Street Address (Ex: 685 US highway 202/206)" 7 | $Suite = Read-Host "Please enter the Suite Number if applicable" 8 | $City = Read-Host "Please enter the City" 9 | $State = Read-Host "Please enter the 2 Letter State (Ex: NJ)" 10 | $BUName = Read-Host "Please enter your BU name (Ex: New Jersey, Pittsburgh, San Antonio)" 11 | Write-host "You entered - Organizational Unit: $OU 12 | Address: $Address 13 | Suite: $Suite 14 | City: $City 15 | State: $State 16 | Office Name: $BUName" -ForegroundColor yellow -BackgroundColor Darkgreen 17 | 18 | $Users = Get-aduser -filter * -Searchbase "$OU" -properties City, l, Office, PhysicalDeliveryOfficeName, StreetAddress, st, state 19 | 20 | $countChange = 0 21 | 22 | Foreach ($User in $Users){ 23 | 24 | "======================================= 25 | Updating Address for $($User.Name) to: 26 | $Address 27 | $Suite 28 | $City, $State 29 | ========================================" 30 | 31 | 32 | Set-ADUser -Identity "$($User.SamAccountName)" -City $City -Office $BUName -StreetAddress "$Address, $Suite" -State $State -l $null 33 | 34 | $countChange++ 35 | 36 | } 37 | 38 | Write-host "===" -ForegroundColor Red 39 | Write-host "Out of a total of $($Users.count) processed employees in $OU 40 | $countChange employee addresses updated" -ForegroundColor Green 41 | Write-Host "===" -ForegroundColor Red -------------------------------------------------------------------------------- /TurnerGUIWPF.ps1: -------------------------------------------------------------------------------- 1 | Add-Type -AssemblyName PresentationFramework 2 | 3 | $xaml = @" 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |