├── 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 |
16 |
17 |
18 |
19 |
20 |
21 | "@
22 |
23 | $reader=(New-Object System.Xml.XmlNodeReader $xaml)
24 | $Window=[Windows.Markup.XamlReader]::Load( $reader )
25 |
26 | $ApplySapFixButton = $Window.FindName("ApplySapFixButton")
27 | $ApplyOfficeMacroFixButton = $Window.FindName("ApplyOfficeMacroFixButton")
28 | $ApplyAllFixesButton = $Window.FindName("ApplyAllFixesButton")
29 | $OutputLog = $Window.FindName("OutputLog")
30 |
31 | $ApplySapFixButton.Add_Click({
32 | $OutputLog.AppendText("SAP Fix applied.`n")
33 | })
34 |
35 | $ApplyOfficeMacroFixButton.Add_Click({
36 | $OutputLog.AppendText("Office Macro Fix applied.`n")
37 | })
38 |
39 | $ApplyAllFixesButton.Add_Click({
40 | $OutputLog.AppendText("All fixes applied.`n")
41 | })
42 |
43 | $Window.ShowDialog()
44 |
--------------------------------------------------------------------------------
/Create-MsoluserFull.ps1:
--------------------------------------------------------------------------------
1 | $First = Read-Host "Enter their First Name"
2 | $Last = Read-Host "Enter their last name"
3 | $DisplayName = $First + " " + $Last
4 | $Email = Read-Host "Enter Email Address"
5 | $Title = Read-Host "Enter Title"
6 | $Office = Read-Host "Enter Office"
7 | $PhoneNumber = Read-Host "Enter Phone number"
8 | $StreetAddress = Read-Host "Enter Street Address"
9 | $City = Read-Host "Enter City"
10 | $State = Read-Host "Enter State"
11 | $Postal = Read-Host "Enter Postal Code"
12 | $Password = Read-Host "Enter Password"
13 |
14 | #Creation of the user
15 | New-Msoluser -UserPrincipalName $Email -FirstName $First -LastName $Last -DisplayName $DisplayName `
16 | -Title $Title -Office $Office -PhoneNumber $PhoneNumber -StreetAddress $StreetAddress -City $City `
17 | -State $State -UsageLocation US -PostalCode $Postal -Password $Password -ForceChangePassword $False
18 |
19 | Write-host = "Breakdown of Licenses"
20 |
21 | #Get The Account SKUS
22 | Get-MsolAccountSku | Select AccountSkuID,ActiveUnits,ConsumedUnits
23 |
24 |
25 | #Add User licenses
26 |
27 | $Option = Read-Host "1 For E1 and Azure RMS, 2 for E3 and Azure RMS"
28 |
29 |
30 |
31 | if($Option -eq "1"){
32 |
33 | Set-Msoluserlicense -UserPrincipalName "$Email" -AddLicenses "NewLeafFlorida:STANDARDPACK","NewLeafFlorida:RIGHTSMANAGEMENT"
34 | Write-Host "E1 and RMS License has been Assigned"
35 | Get-MsolAccountSku | Select AccountSkuID,ActiveUnits,ConsumedUnits
36 |
37 | }
38 | elseif($Option -eq "2"){
39 |
40 | Set-Msoluserlicense -UserPrincipalName "$Email" -AddLicenses "NewLeafFlorida:ENTERPRISEPACK","NewLeafFlorida:RIGHTSMANAGEMENT"
41 | Write-Host "E3 License has been Assigned"
42 | Get-MsolAccountSku | Select AccountSkuID,ActiveUnits,ConsumedUnits
43 |
44 | }#Error
45 | elseif($Option -ne "1" -or "2"){
46 |
47 | Write-Host "No Licenses have been Assigned"
48 | }
--------------------------------------------------------------------------------
/Development/Fileshare Renamer_v2.ps1:
--------------------------------------------------------------------------------
1 | <#Pull List of AD users
2 | Match them to similarities in the other users names
3 | Rename the folder and reshare
4 |
5 | By: Ryan Curran
6 | 7/10/19
7 | #>
8 |
9 | Import-module activedirectory
10 |
11 | $udrivelist = Get-Childitem -Path "\\usnjfs001\H$" -exclude _archive,Batch,Kioware$
12 | $Users = Get-ADuser -Filter {Enabled -eq $True} -Searchbase "OU=Users,OU=US_Excelsior_Medical_Neptune_NJ,OU=Users_And_Computers,DC=medline,DC=COM"
13 |
14 | $Comp = Compare-Object -ReferenceObject $UdriveList.Name -DifferenceObject $Users.SamAccountName
15 |
16 | ForEach ($Complist in $Comp) {
17 |
18 | $UNConvert = $Complist.inputobject
19 | $FNConvert = $Complist.SideIndicator
20 |
21 | #if the side indicator states that the Folder name exists on the fileshare but not in AD, (User may not exist at all or it may be incorrect)
22 |
23 | if ($FNConvert -eq "<=" ) {
24 | #Search AD for a username that is SIMILAR to the fileshare name
25 |
26 | $ADuserRem = $Users | Where-Object {$_.SamAccountName -Like "$UNConvert*"}
27 | #If exists, Pass username to variable to use for RENAMING the folder
28 | <# "User: $($AduserRem.SamAccountname)"
29 | "Folder: $($UNConvert)" #>
30 | $ADuserRem
31 | $ADuserMeasure = $ADuserRem | Measure
32 |
33 | if($Adusermeasure.count -ne '1'){
34 | $UNConvert
35 | $Adusermeasure
36 | }
37 | # Write-Host "$UNConvert is the Foldername"
38 | # Write-Host "$($ADuserRem.SamAccountName) is the correct username"
39 |
40 | #After Folder is renamed, RESHARE as Username$, assign permissions to that user for full control
41 |
42 | } <#ElseIf ($Complist.SideIndicator -eq "=>"){
43 | #These need to be renamed to match AD
44 | Write-host "$($Complist.InputObject) - Exists in AD" -ForegroundColor Red
45 |
46 | #>
47 | Else{
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Development/Fileshare Renamer(Permission pull)_v3.ps1:
--------------------------------------------------------------------------------
1 | #Fileshare Renamer(Permission pull)_v3
2 | #Ryan Curran
3 |
4 | import-module ActiveDirectory
5 |
6 | #$udrivelist = Get-Childitem -Path "\\usnjfs001\H$" -exclude _archive,Batch,Kioware$,rcurran,jbilotti,rraia,vmarzarella
7 |
8 |
9 | ForEach($udl in $udrivelist){
10 |
11 | #isolate the original owners name / permissions
12 | $Accounts = Get-Ntfsaccess -Path "\\usnjfs001\h$\$($udl.name)" | Where-object{$_.Account -notlike "*Admins" -and $_.Account -notlike "S-1*" `
13 | -and $_.Account -notlike "*pa-*" -and $_.Account -notlike "*Users*" -and $_.Account -notlike "NT Authority*" -and $_.Account -notlike "BUILTIN*" `
14 | -and $_.IsInherited -ne $True -and $_.Account -notlike "*rcurran" -and $_.Account -notlike "*jbilotti" -and $_.Account -notlike "*CREATOR*"}
15 |
16 | #Permissions to restore
17 | $Accounts2 = Get-Ntfsaccess -Path "\\usnjfs001\h$\$($udl.name)"
18 |
19 | #Turn make the account name without Medline-NT\
20 | $AccNR = $Accounts.Account.accountname -replace [Regex]::Escape('Medline-nt\'),"" | Where{$_ -ne ""}
21 |
22 | #Add a header
23 | $AccountNameReplace = $AccNR | Select-Object @{Name = "AccountName" ; Expression = {$AccNR}}
24 |
25 | #Bring the two together
26 | $Splat1 = @{
27 | Accountname = "$($AccountNameReplace.AccountName)"
28 | Folder = "$($UDL.Name)"
29 |
30 | }
31 |
32 | $AccountNameReplace
33 | #$UDL | Select *
34 |
35 |
36 | #Rename-Item
37 |
38 |
39 |
40 | <# Try{
41 |
42 | $ADUSers = Get-ADuser -Identity $AccountNameReplace -ErrorAction Stop
43 |
44 |
45 | }Catch{
46 |
47 | $UDL | Select Name,@{Name = Username; Expression={$Accountnamereplace} | Export-csv C:\CSV\UDLFailure.csv -append -NoTypeInformation
48 |
49 | } #>
50 |
51 |
52 |
53 |
54 | #Get-Ntfsaccess -path "\\usnjfs001\h$\$($udl.name)" | Where{$_.Account -notlike ''}
55 |
56 | }
--------------------------------------------------------------------------------
/Disable-IPv6_All_Adapters_GUI_Source.ps1:
--------------------------------------------------------------------------------
1 | $Adapter = Get-NetAdapterBinding |where-Object ComponentID -EQ 'ms_tcpip6' | Where-Object Name -notlike "*Bluetooth*"
2 | Write-Host "---------------------------" -Foregroundcolor Green
3 | Write-Host "| Created By: Ryan Curran |" -ForegroundColor Green
4 | Write-Host "---------------------------" -ForegroundColor Green
5 | "Adapters Loaded`n"
6 | $Val = 1
7 | function AdapterSwitch{
8 | $Title = "Choose options 1, 2 or 3 to proceed."
9 | $Info = Write-host "Would you like to enable or disable IPv6 on all adapters?" -Foregroundcolor Yellow -Backgroundcolor Black
10 |
11 | $options = [System.Management.Automation.Host.ChoiceDescription[]] @("&1. Enable", "&2. Disable", "&3. Quit")
12 | [int]$defaultchoice = 1
13 | $opt = $host.UI.PromptForChoice($Title, $Info , $Options,$defaultchoice)
14 | switch($opt)
15 | {
16 | 0 {
17 |
18 | Write-Host "Enable IPv6" -ForegroundColor Green
19 |
20 | Foreach ($Adapt in $Adapter){
21 |
22 | Enable-netadapterbinding -Name $adapt.name -ComponentID 'ms_tcpip6'
23 | "Enabling $($Adapt.name)'s IPv6"
24 | }
25 | "`nIPv6 has been disabled from $($Adapter.Count) adapters.`n"
26 | $val = 0
27 |
28 | }
29 | 1 {
30 |
31 | Write-Host "Disable IPv6" -ForegroundColor Green
32 |
33 | Foreach ($Adapt in $Adapter){
34 |
35 | Disable-netadapterbinding -Name $adapt.name -ComponentID 'ms_tcpip6'
36 | "Disabling $($Adapt.name)'s IPv6"
37 | }
38 | "`nIPv6 has been disabled from $($Adapter.Count) adapters.`n"
39 | $val = 1
40 |
41 | }
42 | 2 {
43 |
44 | Write-Host "Quit" -ForegroundColor Red
45 | $val = 2
46 | Exit
47 | }
48 | }
49 | }
50 |
51 | While($val -ne 2){
52 | AdapterSwitch
53 | }
54 |
55 |
56 |
--------------------------------------------------------------------------------
/Rename-PC_v2.6-Array.ps1:
--------------------------------------------------------------------------------
1 | $iprange = @(2..253)
2 |
3 | $cred = Get-Credential
4 | $NJOLTS = get-adcomputer -filter {(Name -like "NJOLAP*") -and (Enabled -eq $True)}
5 |
6 | $i = 1
7 |
8 | foreach($ip in $iprange){
9 | '-------------'
10 | "Processing: $i"
11 | $IPAddr = "10.136.138.$ip"
12 | #$IPaddr = "172.22.47.$ip"
13 | $Online = Test-Connection -IPAddress $IPAddr -Quiet -count 1
14 | "Testing Result: Online is $online"
15 |
16 | if($online -eq $True){
17 |
18 | Write-host "Querying: $IPaddr" -ForegroundColor Green
19 |
20 | try{
21 |
22 | $HN = Get-wmiobject -ComputerName $IPAddr -Class Win32_ComputerSystem | Select-Object -ExpandProperty Name -ErrorAction SilentlyContinue
23 |
24 | Write-host "Response Received `nName is: $HN" -ForegroundColor DarkGreen
25 | "Gathered remote hostname"
26 |
27 | if($HN -like "SOMLAP*"){
28 |
29 | $HN2 = $HN.Replace("SOM","NJO")
30 | "Checking $HN to avoid overlapping hostnames"
31 |
32 | if($NJOLTS.name -contains $HN2){
33 |
34 | Write-host "Found an Overlapping Hostname, Cant rename remotely: $HN2" -ForegroundColor Magenta
35 |
36 | }else{
37 |
38 | "Renaming $HN To $HN2"
39 | Rename-computer -Computername $IPAddr -NewName "$HN2" -DomainCredential $Cred
40 |
41 | Write-host "Renaming to $HN2 Completed!" -foreground Yellow -BackgroundColor Black
42 |
43 | }
44 | }else{
45 |
46 | Write-host "$HN does not contain SOMLAP, Skipping" -ForegroundColor Red
47 | }
48 | }catch{
49 |
50 | Write-host "Skipping $IPaddr due to no response" -ForegroundColor Magenta
51 |
52 | }
53 | }else{
54 |
55 | Write-Host "$ipAddr is Offline, Skipping" -ForegroundColor Magenta
56 |
57 | }$i++
58 | }
--------------------------------------------------------------------------------
/PowerShell Learning Script.ps1:
--------------------------------------------------------------------------------
1 | # PowerShell Learning Script
2 |
3 | # 1. Basics:
4 |
5 | # -------------
6 |
7 | Write-Host "Hello, World!" -ForegroundColor Green
8 |
9 | # Variables:
10 |
11 | $name = "John"
12 |
13 | Write-Host "Hello, $name!"
14 |
15 | # Arrays:
16 |
17 | $numbers = 1, 2, 3, 4, 5
18 |
19 | Write-Host "The third number in the array is: $($numbers[2])"
20 |
21 | # 2. Control Structures:
22 |
23 | # -------------------------
24 |
25 | # If statement:
26 |
27 | $age = 25
28 |
29 | if ($age -lt 20) {
30 |
31 | Write-Host "You are a teenager."
32 |
33 | } elseif ($age -lt 30) {
34 |
35 | Write-Host "You are in your twenties."
36 |
37 | } else {
38 |
39 | Write-Host "You are older than 30."
40 |
41 | }
42 |
43 | # For loop:
44 |
45 | for ($i=0; $i -lt 5; $i++) {
46 |
47 | Write-Host "Loop iteration: $i"
48 |
49 | }
50 |
51 | # 3. Functions:
52 |
53 | # ---------------
54 |
55 | function Greet-User {
56 |
57 | param (
58 |
59 | [string]$username = "Guest"
60 |
61 | )
62 |
63 | Write-Host "Hello, $username!"
64 |
65 | }
66 |
67 | # Calling a function:
68 |
69 | Greet-User -username "Alice"
70 |
71 | # 4. Working with Files:
72 |
73 | # -------------------------
74 |
75 | # Creating a new file:
76 |
77 | New-Item -Path 'C:\temp\example.txt' -ItemType File -Force
78 |
79 | # Writing to a file:
80 |
81 | Add-Content -Path 'C:\temp\example.txt' -Value 'This is a sample text.'
82 |
83 | # Reading from a file:
84 |
85 | $content = Get-Content -Path 'C:\temp\example.txt'
86 |
87 | Write-Host "Content of the file: $content"
88 |
89 | # 5. Error Handling:
90 |
91 | # ---------------------
92 |
93 | try {
94 |
95 | $result = 1/0 # This will cause an error (division by zero)
96 |
97 | } catch {
98 |
99 | Write-Host "An error occurred: $_" -ForegroundColor Red
100 |
101 | }
102 |
103 | # 6. Explore More:
104 |
105 | # -----------------
106 |
107 | # You can explore more commands and their details using 'Get-Command' and 'Get-Help':
108 |
109 | # Get-Command
110 |
111 | # Get-Help
--------------------------------------------------------------------------------
/Report-Hostname_OS.ps1:
--------------------------------------------------------------------------------
1 | Import-module activedirectory
2 |
3 |
4 |
5 |
6 | Set-location AD:
7 |
8 | #assign Get-location to the variable $local
9 | $local = Get-Location
10 |
11 |
12 | #While the path of local is not equal to AD:\ go up a directory and update the location for variable $local
13 | while($local.path -ne "AD:\"){
14 |
15 | cd ..
16 |
17 | $local = Get-Location
18 | $local.path
19 | }
20 |
21 | #Set the location of the powershell window to AD:\
22 | set-location ad:
23 |
24 | Write-Host "Choose the location to go to to pull the report"
25 | Write-Host "1. Excelsior Desktops"
26 | Write-Host "2. Excelsior Laptops"
27 | Write-Host "3. All"
28 |
29 | $Location = Read-Host "Location"
30 |
31 | if($Location -eq "Excelsior Laptops" -or $Location -eq "2") {
32 |
33 | Set-location ""
34 | Get-Adcomputer -Filter * -Properties * | Select Name, OperatingSystem | Export-csv "C:\CSV\Excelsior_Laptops$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv" -NoTypeInformation
35 | Write-Host "Report Has Been Created. It is named Excelsior_Laptops_$([DateTime]::Now.ToSTring("MM-dd-yyyy-hh.mm.ss")).csv"
36 |
37 | #if a desktop run script
38 | }elseif($Location -eq "Excelsior Desktops" -or $Location -eq "1"){
39 |
40 | Set-location ""
41 | Get-Adcomputer -Filter * -Properties * | Select Name, OperatingSystem | Export-csv "C:\CSV\Excelsior_Desktops$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv" -NoTypeInformation
42 | Write-Host "Report Has Been Created. It is named Excelsior_Desktops_$([DateTime]::Now.ToSTring("MM-dd-yyyy-hh.mm.ss")).csv"
43 |
44 | }elseif($Location -eq "All" -or $Location -eq "3"){
45 |
46 | Set-location ""
47 | Get-Adcomputer -Filter * -Properties * | Select Name, OperatingSystem | Export-csv "C:\CSV\Excelsior_Computers_All_$([DateTime]::Now.ToString("MM-dd-yyyy-hh.mm.ss")).csv" -NoTypeInformation
48 | Write-Host "Report Has Been Created. It is named Excelsior_computers_all_$([DateTime]::Now.ToSTring("MM-dd-yyyy-hh.mm.ss")).csv"
49 |
50 | #if none then exit
51 | }else{
52 |
53 | }
54 | #if no options selected at beginning, exit
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/Report-MDMEnrollment.ps1:
--------------------------------------------------------------------------------
1 | import-module importexcel
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 | 'OU=Users,OU=Mahwah,OU=North East,OU=Offices,DC=tcco,DC=org'
10 | 'OU=Users,OU=TSIB,OU=North East,OU=Offices,DC=tcco,DC=org'
11 | )
12 |
13 | #Establish variables and arrays
14 | $OURegex = [String]::Join('|',$OUS)
15 | $mdmnew = @()
16 | $usernew= @()
17 |
18 | #Get List of group members for MDM
19 | $mdm = get-adgroupmember -Identity TUR.ALL.MDM.USERS
20 |
21 | #Foreach user object in $MDM, check to see if their distinguished name has one of the OUs, If $True run a Get-ADuser search and save to $mdmNew
22 | Foreach($m in $mdm){
23 | if($m.DistinguishedName -match $OURegex){
24 | $mdmArray = get-aduser -identity $m.samaccountname -properties displayname | select Displayname
25 | $mdmNew += $mdmArray
26 | $mdmArray
27 | }else{
28 |
29 | }
30 | }
31 |
32 |
33 | #Foreach OU from $OUs list to get the comparison array then compare it against mdmNew and export to excel PANJMDMUsers for two categories, completed and not enrolled.
34 | ForEach($OU in $OUs){
35 | "Running for $OU"
36 | $Users = Get-aduser -SearchBase $OU -Filter * -properties Displayname | Select displayName
37 | $userIn1 = Compare-Object -DifferenceObject $users.displayname -ReferenceObject $mdmNew.displayname -IncludeEqual -ExcludeDifferent
38 | $userIn += $userIn1
39 | $userEx = Compare-Object -DifferenceObject $users.displayname -ReferenceObject $mdmNew.displayname
40 | $userEx | export-excel -WorksheetName "Not Enrolled" -path C:\temp\PANJMDMUsers-$([DateTime]::Now.ToSTring("MM-dd-yyyy")).xlsx -Append -Autosize -Title "Not yet Enrolled" -Autofilter
41 |
42 | }
43 |
44 | $userIn | export-excel -Worksheetname "Enrolled" -path C:\Temp\PANJMDMUsers-$([DateTime]::Now.ToSTring("MM-dd-yyyy")).xlsx -Append -Autosize -Title "Enrolled" -Autofilter
45 |
--------------------------------------------------------------------------------
/Report-GetNetworkAdapterConfig.ps1:
--------------------------------------------------------------------------------
1 | # Credit: TechiBee.com
2 | #
3 | # http://techibee.com/powershell/powershell-get-ip-address-subnet-gateway-dns-serves-and-mac-address-details-of-remote-computer/1367
4 | #
5 |
6 |
7 |
8 | [cmdletbinding()]
9 | param (
10 | [parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
11 | [string[]]$ComputerName = $env:computername
12 | )
13 |
14 | begin {}
15 | process {
16 | foreach ($Computer in $ComputerName) {
17 | if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) {
18 | try {
19 | $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer -EA Stop | ? {$_.IPEnabled}
20 | } catch {
21 | Write-Warning "Error occurred while querying $computer."
22 | Continue
23 | }
24 | foreach ($Network in $Networks) {
25 | $IPAddress = $Network.IpAddress[0]
26 | $SubnetMask = $Network.IPSubnet[0]
27 | $DefaultGateway = $Network.DefaultIPGateway
28 | $DNSServers = $Network.DNSServerSearchOrder
29 | $WINS1 = $Network.WINSPrimaryServer
30 | $WINS2 = $Network.WINSSecondaryServer
31 | $WINS = @($WINS1,$WINS2)
32 | $IsDHCPEnabled = $false
33 | If($network.DHCPEnabled) {
34 | $IsDHCPEnabled = $true
35 | }
36 | $MACAddress = $Network.MACAddress
37 | $OutputObj = New-Object -Type PSObject
38 | $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
39 | $OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress
40 | $OutputObj | Add-Member -MemberType NoteProperty -Name SubnetMask -Value $SubnetMask
41 | $OutputObj | Add-Member -MemberType NoteProperty -Name Gateway -Value ($DefaultGateway -join ",")
42 | $OutputObj | Add-Member -MemberType NoteProperty -Name IsDHCPEnabled -Value $IsDHCPEnabled
43 | $OutputObj | Add-Member -MemberType NoteProperty -Name DNSServers -Value ($DNSServers -join ",")
44 | $OutputObj | Add-Member -MemberType NoteProperty -Name WINSServers -Value ($WINS -join ",")
45 | $OutputObj | Add-Member -MemberType NoteProperty -Name MACAddress -Value $MACAddress
46 | $OutputObj
47 | }
48 | }
49 | }
50 | }
51 |
52 | end {}
--------------------------------------------------------------------------------
/Rename-PC_v2.ps1:
--------------------------------------------------------------------------------
1 | # Establish Static Variables
2 | Import-module activedirectory
3 |
4 | $PreNew = read-host "Enter new prefix"
5 | $PreOld = read-host "Enter old prefix"
6 | $Cred = Get-Credential
7 | $OldName = "*$($Preold)LAP*"
8 |
9 | $Laptops = get-adcomputer -filter {Name -like $OldName} | Select-Object Name
10 |
11 | #$lap = read-host "what is the name of the laptop?"
12 |
13 |
14 | # Next we build the code structure for a foreach loop
15 |
16 | Foreach ($laptop in $laptops.name){
17 |
18 | "testing laptop $laptop"
19 | #run a test connection once, by using the -quiet flag it will return a boolean response of $True or $False
20 |
21 | $testcon = test-connection -Computername $laptop -count 1 -quiet
22 |
23 | IF ($testcon -eq $True){
24 |
25 | Write-host "$Laptop pinged $testcon" -ForegroundColor Green
26 |
27 | #we need to get the IP of the laptop to re-query it and verify that the hostname matches the hostname from $laptop
28 |
29 | $testcon2 = test-connection -ComputerName $laptop -count 1
30 |
31 | Write-host "IP is $($testcon2.ipv4address)" -ForegroundColor Green
32 | Write-Host "Verifying hostname against original hostname $laptop"
33 |
34 | $verify = get-wmiobject -Computername $testcon2.IPv4address -Class Win32_ComputerSystem | Select-Object -ExpandProperty name
35 | "Hostname from remote computer is $($Verify)"
36 |
37 | IF ($Verify -eq $laptop){
38 |
39 | Write-host "$Verify matches the hostname $laptop, proceeding with renaming" -ForegroundColor Green
40 | #change the hostname to the new one using .replace
41 | $hnNew = $laptop.replace("$PreOld","$PreNew")
42 | Rename-computer -ComputerName $laptop -NewName $hnNew -Force -DomainCredential $Cred
43 |
44 | }else{
45 | Write-host "$Laptop failed renaming, exporting" -ForegroundColor Red
46 | $laptop | Export-csv C:\Temp\FailedRename.csv -Append -NoTypeInformation
47 |
48 | }
49 | }else {
50 |
51 | Write-host "$Laptop failed the test ping, exporting the hostname" -ForegroundColor Red
52 |
53 | $laptop | Export-csv C:\temp\FailedRename.csv -Append -NoTypeInformation
54 | }
55 |
56 | }
--------------------------------------------------------------------------------
/Get-RemoteServicetag_CSV.ps1:
--------------------------------------------------------------------------------
1 | #Script for pulling service tags from computers
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 |
15 | $i = 0
16 |
17 | Write-host "Select the List of Computers to Pull Data From" -ForegroundColor Green
18 | #Use Function to Get the CSV list of Computers
19 | $Comps = Get-FileName
20 |
21 | $PCS = Import-csv $Comps
22 |
23 | Write-host "What is your IP(VPN if off network) or Hostname" -ForegroundColor Green
24 | $HN = Read-Host "IP or Hostname"
25 |
26 |
27 | ForEach($PC in $PCS){
28 |
29 | $i++
30 |
31 | #Show progress of the count
32 | Write-Progress -Activity "Pulling Data from List" -Status "Testing Ping on: $i of $($PCs.count)"
33 | Write-Host "Testing $($PC.'Computer Name')"
34 |
35 | $TC = Test-connection $($PC.'IPv4 Addresses') -Quiet -Count 1
36 |
37 |
38 | if ($TC -eq $True){
39 |
40 | Write-Host "Connecting to $($PC.'Computer Name') and Pulling Serial Number" -ForegroundColor Green
41 | psexec -nobanner \\172.16.155.119 -u tcco\rcurran -p powershell Get-Wmiobject -class win32_bios | Select PSComputername, Serialnumber | Set-Content \\$($HN)\Temp\ServiceTags$([DateTime]::Now.ToSTring("MM-dd-yyyy")).csv -append
42 | $SN = wmic bios get serialnumber
43 | $HN = Hostname
44 | $SN | Select @{Name = "Serial Number";Expression = {${$SN.SerialNumber}}}, @{Name = "HostName";Expression = {$HN}} | Set-Content \\SOMLAP0107\C$\Temp\Export.csv
45 |
46 | exit
47 |
48 | }else{
49 |
50 | Write-Host "$($PC.'Computer Name') Failed the Ping Test" -ForegroundColor Red
51 | $PC | Select @{Name = "Computer Name"; Expression = {$($PC.'Computer Name')}}, @{Name = "Last user"; Expression = {$($PC.'Last User')}}, @{Name = "Last Active"; Expression = {$($PC.'Last Active')}} | Export-csv C:\Temp\FailedHostnames.csv -Append -NoTypeinformation
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/Restore-DeletedADObject.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Recover deleted computer and BitLocker recovery objects from AD.
4 |
5 | .DESCRIPTION
6 | This script prompts for a hostname, searches for deleted AD computer and BitLocker recovery objects,
7 | allows the user to select from a list, and restores the selected items.
8 |
9 | .NOTES
10 | Author: Ryan Curran
11 | Created: 2025-04-22
12 | Version: 1.0
13 | Requirements: Active Directory module, AD Recycle Bin enabled
14 | #>
15 |
16 | #region Prerequisites
17 | Import-Module ActiveDirectory -ErrorAction Stop
18 | #endregion
19 |
20 | #region Functions
21 | function Write-Log {
22 | param (
23 | [string]$Message,
24 | [string]$Level = "INFO"
25 | )
26 | $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
27 | Write-Host "[$timestamp] [$Level] $Message"
28 | }
29 |
30 | function Get-DeletedObjectsByHostname {
31 | param (
32 | [string]$hostname
33 | )
34 |
35 | Write-Log "Searching for deleted objects matching hostname '$hostname'..."
36 | $filter = "Name -like '*$hostname*'"
37 | $deletedObjects = Get-ADObject -Filter $filter -IncludeDeletedObjects -Properties *
38 | $deletedObjects | Where-Object { $_.ObjectClass -in 'computer', 'msFVE-RecoveryInformation' }
39 | }
40 | #endregion
41 |
42 | #region Main Logic
43 | try {
44 | $hostname = Read-Host "Enter the hostname of the deleted device"
45 |
46 | $objects = Get-DeletedObjectsByHostname -hostname $hostname
47 |
48 | if (-not $objects) {
49 | Write-Log "No deleted objects found for '$hostname'." "WARN"
50 | exit
51 | }
52 |
53 | Write-Log "Displaying deleted objects for selection..."
54 | $selected = $objects | Select-Object Name, ObjectClass, DistinguishedName, LastKnownParent, Type |
55 | Out-GridView -Title "Select objects to restore" -PassThru -OutputMode Multiple
56 |
57 | if (-not $selected) {
58 | Write-Log "No objects selected. Exiting." "INFO"
59 | exit
60 | }
61 |
62 | foreach ($obj in $selected) {
63 | Write-Log "Restoring: $($obj.Name) [$($obj.ObjectClass)]"
64 | Restore-ADObject -Identity $obj.DistinguishedName
65 | }
66 |
67 | Write-Log "Selected objects restored successfully." "SUCCESS"
68 |
69 | } catch {
70 | Write-Log "An error occurred: $_" "ERROR"
71 | }
72 | #endregion
73 |
--------------------------------------------------------------------------------
/NTFSAccesss_Pit.ps1:
--------------------------------------------------------------------------------
1 | #Made specifically for \\pitfile1\data
2 |
3 | #Directory selection for report export
4 | Function Get-FolderName($InitialDirectory)
5 | {
6 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
7 |
8 | $OpenFolderDialog = New-Object System.Windows.Forms.FolderBrowserDialog
9 | #$OpenFolderDialog.initialDirectory = $initialDirectory
10 | #$OpenFileDialog.filter = "CSV (*.csv) | *.csv"
11 | $OpenFolderDialog.ShowDialog() | Out-Null
12 | $OpenFolderDialog.SelectedPath
13 | }
14 |
15 | Write-host "Select Your Export Directory" -ForegroundColor Yellow -BackgroundColor Black
16 | #call to Get-Foldername function to select export directory
17 | $Directory = Get-FolderName
18 | Write-host "Export Directory of $Directory has been selected" -ForegroundColor Green -BackgroundColor Black
19 |
20 | #GetNTFSaccess for Pitroot
21 | Write-host "Getting NTFSAccess for \\pitfile1\Data" -ForegroundColor Yellow -BackgroundColor Black
22 | $PitRoot = Get-NTFSAccess \\pitfile1\Data
23 | $PitRoot | Export-csv "$($Directory)\Report_PitFile1_Data_DirPerms_$([DateTime]::Now.ToSTring("MM-dd-yyyy")).csv" -NoTypeInformation
24 | Write-host "NTFS Permissions for $Directory have been exported" -ForegroundColor Green -BackgroundColor Black
25 |
26 | Write-host "Getting Childitem list for \\Pitfile1\Data\, Recursion depth of 2, Directory only - This may take a few minutes" -ForegroundColor Yellow -BackgroundColor Black
27 | #Designate the scan path
28 | $SubDir = Get-Childitem -Path \\Pitfile1\Data\ -Directory -Recurse -Depth 2
29 | Write-host "Childitem locations have been collected" -ForegroundColor Green -BackgroundColor Black
30 |
31 | #Set value of 0 for progress bar
32 | $i = 0
33 |
34 | #Run foreach loop on the contents of Subdir with the Get-ntfsaccess command
35 | ForEach ($subdirscan in $Subdir){
36 |
37 | Write-progress -Activity "Reading NTFS Permissions" -CurrentOperation "$($subdirscan.name)" -Status "Processing $($Subdirscan.name): $i of $($Subdir.count)" -PercentComplete ($i/$($Subdir.name.count)*100);
38 | #Get-ntfsaccess -Path "$($subdirscan.Fullname)"
39 | Write-host "Exporting $($Subdirscan.name)" -ForegroundColor Green -BackgroundColor Black
40 | Get-Ntfsaccess -path "$($subdirscan.Fullname)" | Export-csv "$($Directory)\Report_PitFile1_Data_DirPerms_$([DateTime]::Now.ToSTring("MM-dd-yyyy")).csv" -NoTypeInformation -Append
41 |
42 | $i++
43 |
44 | }
--------------------------------------------------------------------------------
/CopyAdd-WifiProfile_Manual.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 |
15 | $i = 0
16 |
17 | Write-Host "Select the Shortcut to Transfer" -ForegroundColor Green
18 | #Use Function to Get the File to transfer
19 | $FileToTransfer = Get-FileName
20 |
21 | Write-host "Select the List of Computers to transfer the shortcut to" -ForegroundColor Green
22 | #Use Function to Get the CSV list of Computers
23 | $PCs = Read-host "Enter hostname"
24 |
25 | Write-Host "You Selected the Path $XML" -ForegroundColor Green
26 |
27 | #Run a ForEach on each hostname in $PCs Assign it to $PC
28 | ForEach($PC in $PCs){
29 | #Increment $i from 0 to get a count
30 | $i++
31 | #Show progress of the count
32 | Write-Progress -Activity "Installing new MEDLINE SSID" -Status "Installed: $i of $($PCs.count)"
33 |
34 | Write-Host "Testing $PC for Activity" -ForegroundColor Green
35 | #Test each computer and assign the value to $tp if it returns $True, run the script, if not export an error to an error log
36 | $tp = Test-Connection -ComputerName $PC -quiet -Count 1
37 |
38 | if($tp -eq $True){
39 | #Write-Host "I AM ONLINE $($PC.Hostname)"
40 | Write-Host "Copying to $PC" -ForegroundColor Green
41 |
42 | #Copy the file to the remote computer
43 | xcopy $FileToTransfer "\\$PC\C$\"
44 |
45 | #remote execute the netsh add for the wireless profile
46 | PsExec64.exe "\\$PC" cmd.exe /c "netsh wlan add profile filename=C:\MEDLINE.xml User=All"
47 |
48 | #remote execute the deletion of the wireless profile XML
49 | PsExec64.exe "\\$PC" cmd.exe /c "del C:\MEDLINE.XML"
50 |
51 | #remote execute the deletion of the wireless profile
52 | PsExec64.exe "\\$PC" cmd.exe /c "netsh wlan delete profile name=excmed"
53 |
54 | }else{
55 | Write-Host "$PC Is Unavailable" -ForegroundColor Red
56 | $PC | Select @{Name = "Hostname"; Expression = {$PC}} | Export-csv C:\CSV\FailedHostnames$([DateTime]::Now.ToSTring("MM-dd-yyyy-hh.mm.ss")).csv -Append -Notypeinformation
57 |
58 | }
59 |
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/Rename-PC_v2.5.ps1:
--------------------------------------------------------------------------------
1 | # Establish Static Variables
2 | Import-module activedirectory
3 |
4 | $PreNew = read-host "Enter new prefix"
5 | $PreOld = read-host "Enter old prefix"
6 | $Cred = Get-Credential
7 | $OldName = "*$($Preold)LAP*"
8 |
9 | $Laptops = Function Get-FileName
10 | {
11 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
12 |
13 | $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
14 | #$OpenFileDialog.initialDirectoiry = $initialDirectory
15 | $OpenFileDialog.filter = "CSV (*.csv) | *.csv"
16 | $OpenFileDialog.ShowDialog() | Out-Null
17 | }
18 |
19 | #$lap = read-host "what is the name of the laptop?"
20 |
21 |
22 | # Next we build the code structure for a foreach loop
23 |
24 | Foreach ($laptop in $laptops.name){
25 |
26 | "testing laptop $laptop"
27 | #run a test connection once, by using the -quiet flag it will return a boolean response of $True or $False
28 |
29 | $testcon = test-connection -Computername $laptop -count 1 -quiet
30 |
31 | IF ($testcon -eq $True){
32 |
33 | Write-host "$Laptop pinged $testcon" -ForegroundColor Green
34 |
35 | #we need to get the IP of the laptop to re-query it and verify that the hostname matches the hostname from $laptop
36 |
37 | $testcon2 = test-connection -ComputerName $laptop -count 1
38 |
39 | Write-host "IP is $($testcon2.ipv4address)" -ForegroundColor Green
40 | Write-Host "Verifying hostname against original hostname $laptop"
41 |
42 | $verify = get-wmiobject -Computername $testcon2.IPv4address -Class Win32_ComputerSystem | Select-Object -ExpandProperty name
43 | "Hostname from remote computer is $($Verify)"
44 |
45 | IF ($Verify -eq $laptop){
46 |
47 | Write-host "$Verify matches the hostname $laptop, proceeding with renaming" -ForegroundColor Green
48 | #change the hostname to the new one using .replace
49 | $hnNew = $laptop.replace("$PreOld","$PreNew")
50 | Rename-computer -ComputerName $laptop -NewName $hnNew -Force -DomainCredential $Cred
51 |
52 | }else{
53 | Write-host "$Laptop failed renaming, exporting" -ForegroundColor Red
54 | $laptop | Export-csv C:\Temp\FailedRename.csv -Append -NoTypeInformation
55 |
56 | }
57 | }else {
58 |
59 | Write-host "$Laptop failed the test ping, exporting the hostname" -ForegroundColor Red
60 |
61 | $laptop | Export-csv C:\temp\FailedRename.csv -Append -NoTypeInformation
62 | }
63 |
64 | }
--------------------------------------------------------------------------------
/Get_GPS_Without_Admin.ps1:
--------------------------------------------------------------------------------
1 |
2 | function Get-ComputerGeoLocation ()
3 | {
4 |
5 | # Windows Location API
6 | $mylocation = new-object –ComObject LocationDisp.LatLongReportFactory
7 |
8 | # Get Status
9 | $mylocationstatus = $mylocation.status
10 | If ($mylocationstatus -eq “4”)
11 | {
12 | # Windows Location Status returns 4, so we’re “Running”
13 |
14 | # Get Latitude and Longitude from LatlongReport property
15 | $latitude = $mylocation.LatLongReport.Latitude
16 | $longitude = $mylocation.LatLongReport.Longitude
17 |
18 | if ($latitude -ne $null -or $longitude -ne $Null)
19 | {
20 | # Retrieve Geolocation from Google Geocoding API
21 | $webClient = New-Object System.Net.WebClient
22 | Write-host “Retrieving geolocation for” $($latitude) $($longitude)
23 | $url = “https://maps.googleapis.com/maps/api/geocode/xml?latlng=$latitude,$longitude&sensor=true”
24 | $locationinfo = $webClient.DownloadString($url)
25 |
26 | [xml]$doc = $locationinfo
27 | # Verify the response
28 | if ($doc.GeocodeResponse.status -eq “OK”)
29 | {
30 | $street_address = $doc.GeocodeResponse.result | Select-Object -Property formatted_address, Type | Where-Object -Property Type -eq “street_address”
31 | $geoobject = New-Object -TypeName PSObject
32 | $geoobject | Add-Member -MemberType NoteProperty -Name Address -Value $street_address.formatted_address
33 | $geoobject | Add-Member -MemberType NoteProperty -Name latitude -Value $mylocation.LatLongReport.Latitude
34 | $geoobject | Add-Member -MemberType NoteProperty -Name longitude -Value $mylocation.LatLongReport.longitude
35 | $geoobject | format-list
36 | }
37 | Else
38 | {
39 | Write-Warning “Request failed, unable to retrieve Geo locatiion information from Geocoding API”
40 | }
41 | }
42 | Else
43 | {
44 | write-warning “Latitude or Longitude data missing”
45 | }
46 | }
47 |
48 | Else
49 | {
50 | switch($mylocationstatus)
51 | {
52 | # All possible status property values as defined here:
53 | # http://msdn.microsoft.com/en-us/library/windows/desktop/dd317716(v=vs.85).aspx
54 | 0 {$mylocationstatuserr = “Report not supported”}
55 | 1 {$mylocationstatuserr = “Error”}
56 | 2 {$mylocationstatuserr = “Access denied”}
57 | 3 {$mylocationstatuserr = “Initializing” }
58 | 4 {$mylocationstatuserr = “Running”}
59 | }
60 |
61 | If ($mylocationstatus -eq “3”)
62 | {
63 | write-host “Windows Loction platform is $mylocationstatuserr”
64 | sleep 5
65 | Get-ComputerGeoLocation
66 | }
67 | Else
68 | {
69 | write-warning “Windows Loction platform: Status:$mylocationstatuserr”
70 | }
71 | }
72 | } # end function
73 | Get-ComputerGeoLocation
--------------------------------------------------------------------------------
/Development/Percent-Change/Percent-Change/Percent-Change/obj/Debug/App.g.i.cs:
--------------------------------------------------------------------------------
1 | #pragma checksum "..\..\App.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "565A25AB8EC14FBDF3DFC7F3DB0B2F72CE50407BA27588FBF3D2BB80FE4B1566"
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version:4.0.30319.42000
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | //------------------------------------------------------------------------------
11 |
12 | using Percent_Change;
13 | using System;
14 | using System.Diagnostics;
15 | using System.Windows;
16 | using System.Windows.Automation;
17 | using System.Windows.Controls;
18 | using System.Windows.Controls.Primitives;
19 | using System.Windows.Data;
20 | using System.Windows.Documents;
21 | using System.Windows.Ink;
22 | using System.Windows.Input;
23 | using System.Windows.Markup;
24 | using System.Windows.Media;
25 | using System.Windows.Media.Animation;
26 | using System.Windows.Media.Effects;
27 | using System.Windows.Media.Imaging;
28 | using System.Windows.Media.Media3D;
29 | using System.Windows.Media.TextFormatting;
30 | using System.Windows.Navigation;
31 | using System.Windows.Shapes;
32 | using System.Windows.Shell;
33 |
34 |
35 | namespace Percent_Change {
36 |
37 |
38 | ///
39 | /// App
40 | ///
41 | public partial class App : System.Windows.Application {
42 |
43 | ///
44 | /// InitializeComponent
45 | ///
46 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
47 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
48 | public void InitializeComponent() {
49 |
50 | #line 5 "..\..\App.xaml"
51 | this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
52 |
53 | #line default
54 | #line hidden
55 | }
56 |
57 | ///
58 | /// Application Entry Point.
59 | ///
60 | [System.STAThreadAttribute()]
61 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
62 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
63 | public static void Main() {
64 | Percent_Change.App app = new Percent_Change.App();
65 | app.InitializeComponent();
66 | app.Run();
67 | }
68 | }
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/Development/Percent-Change/Percent-Change/Percent-Change/obj/Release/App.g.cs:
--------------------------------------------------------------------------------
1 | #pragma checksum "..\..\App.xaml" "{8829d00f-11b8-4213-878b-770e8597ac16}" "565A25AB8EC14FBDF3DFC7F3DB0B2F72CE50407BA27588FBF3D2BB80FE4B1566"
2 | //------------------------------------------------------------------------------
3 | //
4 | // This code was generated by a tool.
5 | // Runtime Version:4.0.30319.42000
6 | //
7 | // Changes to this file may cause incorrect behavior and will be lost if
8 | // the code is regenerated.
9 | //
10 | //------------------------------------------------------------------------------
11 |
12 | using Percent_Change;
13 | using System;
14 | using System.Diagnostics;
15 | using System.Windows;
16 | using System.Windows.Automation;
17 | using System.Windows.Controls;
18 | using System.Windows.Controls.Primitives;
19 | using System.Windows.Data;
20 | using System.Windows.Documents;
21 | using System.Windows.Ink;
22 | using System.Windows.Input;
23 | using System.Windows.Markup;
24 | using System.Windows.Media;
25 | using System.Windows.Media.Animation;
26 | using System.Windows.Media.Effects;
27 | using System.Windows.Media.Imaging;
28 | using System.Windows.Media.Media3D;
29 | using System.Windows.Media.TextFormatting;
30 | using System.Windows.Navigation;
31 | using System.Windows.Shapes;
32 | using System.Windows.Shell;
33 |
34 |
35 | namespace Percent_Change {
36 |
37 |
38 | ///
39 | /// App
40 | ///
41 | public partial class App : System.Windows.Application {
42 |
43 | ///
44 | /// InitializeComponent
45 | ///
46 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
47 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
48 | public void InitializeComponent() {
49 |
50 | #line 5 "..\..\App.xaml"
51 | this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
52 |
53 | #line default
54 | #line hidden
55 | }
56 |
57 | ///
58 | /// Application Entry Point.
59 | ///
60 | [System.STAThreadAttribute()]
61 | [System.Diagnostics.DebuggerNonUserCodeAttribute()]
62 | [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
63 | public static void Main() {
64 | Percent_Change.App app = new Percent_Change.App();
65 | app.InitializeComponent();
66 | app.Run();
67 | }
68 | }
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/Disable-Bluebeam_Updates.ps1:
--------------------------------------------------------------------------------
1 | Function Check-RunAsAdministrator()
2 | {
3 | #Get current user context
4 | $CurrentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
5 |
6 | #Check user is running the script is member of Administrator Group
7 | if($CurrentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator))
8 | {
9 | Write-host "Script is running with Administrator privileges!"
10 | }
11 | else
12 | {
13 | #Create a new Elevated process to Start PowerShell
14 | $ElevatedProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell";
15 |
16 | # Specify the current script path and name as a parameter
17 | $ElevatedProcess.Arguments = "& '" + $script:MyInvocation.MyCommand.Path + "'"
18 |
19 | #Set the Process to elevated
20 | $ElevatedProcess.Verb = "runas"
21 |
22 | #Start the new elevated process
23 | [System.Diagnostics.Process]::Start($ElevatedProcess)
24 |
25 | #Exit from the current, unelevated, process
26 | Exit
27 |
28 | }
29 | }
30 |
31 | #Check Script is running with Elevated Privileges
32 | Check-RunAsAdministrator
33 |
34 |
35 | function UpdateSwitch{
36 | $Title = "Choose options 1, 2 or 3 to proceed."
37 | $Info = Write-host "Would you like to enable or disable Bluebeam updates?" -Foregroundcolor Yellow -Backgroundcolor Black
38 |
39 | $options = [System.Management.Automation.Host.ChoiceDescription[]] @("&1. Enable", "&2. Disable", "&3. Quit")
40 | [int]$defaultchoice = 1
41 | $opt = $host.UI.PromptForChoice($Title, $Info , $Options,$defaultchoice)
42 | switch($opt)
43 | {
44 | 0 {
45 |
46 | Write-Host "Enabling Bluebeam Updates" -ForegroundColor Green
47 |
48 | Set-ItemProperty -Path "HKLM:\Software\Bluebeam Software\20\Revu" -Name "DisableInAppUpdates" -Value "0"
49 |
50 | "`nBluebeam Updates has been Enabled.`n"
51 | $val = 0
52 |
53 | }
54 | 1 {
55 |
56 | Write-Host "Disable Bluebeam Updates" -ForegroundColor Green
57 |
58 | Set-ItemProperty -Path "HKLM:\Software\Bluebeam Software\20\Revu" -Name "DisableInAppUpdates" -Value "1"
59 |
60 | "`nBluebeam Updates has been Disabled.`n"
61 |
62 | $val = 1
63 |
64 | }
65 | 2 {
66 |
67 | Write-Host "Quit" -ForegroundColor Red
68 | $val = 2
69 | Exit
70 | }
71 | }
72 | }
73 |
74 | While($val -ne 2){
75 | UpdateSwitch
76 | }
--------------------------------------------------------------------------------
/Development/Percent-Change/Percent-Change/Percent-Change/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("Percent-Change")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("Percent-Change")]
15 | [assembly: AssemblyCopyright("Copyright © 2019")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/Development/Percent-Change/Percent-Change/Percent-Change/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
25 |
34 |
43 |
51 |
59 |
67 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/Disable-Bluebeam_Updates_GUI.ps1:
--------------------------------------------------------------------------------
1 | Write-Host "---------------------------" -Foregroundcolor Green
2 | Write-Host "| Created By: Ryan Curran |" -ForegroundColor Green
3 | Write-Host "---------------------------" -ForegroundColor Green
4 |
5 | "`n"
6 |
7 | "This patch will work for 20.x.x version of Bluebeam only (currently)`n"
8 | function UpdateSwitch{
9 | $Title = "Choose options 1, 2 or 3 to proceed."
10 | $Info = Write-host "Would you like to enable or disable Bluebeam update prompt (Help -> Check For Updates)?" -Foregroundcolor Yellow -Backgroundcolor Black
11 |
12 | $options = [System.Management.Automation.Host.ChoiceDescription[]] @("&1. Enable", "&2. Disable", "&3. Quit")
13 | [int]$defaultchoice = 1
14 | $opt = $host.UI.PromptForChoice($Title, $Info , $Options,$defaultchoice)
15 | switch($opt)
16 | {
17 | 0 {
18 | cls
19 |
20 | Write-Host "---------------------------" -Foregroundcolor Green
21 | Write-Host "| Created By: Ryan Curran |" -ForegroundColor Green
22 | Write-Host "---------------------------" -ForegroundColor Green
23 |
24 | "`n"
25 |
26 | Write-Host "Option Selected: Enabling Bluebeam Updates." -ForegroundColor Green
27 |
28 | Set-ItemProperty -Path "HKLM:\Software\Bluebeam Software\20\Revu" -Name "DisableInAppUpdates" -Value "0"
29 |
30 | Write-Host "`nBluebeam Updates has been Enabled.`n" -ForegroundColor Green
31 | Write-Host "`nClose and re-open Bluebeam for the changes to take effect.`n" -ForegroundColor Green
32 |
33 | $val = 0
34 |
35 | }
36 | 1 {
37 | cls
38 |
39 | Write-Host "---------------------------" -Foregroundcolor Green
40 | Write-Host "| Created By: Ryan Curran |" -ForegroundColor Green
41 | Write-Host "---------------------------" -ForegroundColor Green
42 |
43 | "`n"
44 | Write-Host "Option Selected: Disable Bluebeam Updates." -ForegroundColor Green
45 |
46 | Set-ItemProperty -Path "HKLM:\Software\Bluebeam Software\20\Revu" -Name "DisableInAppUpdates" -Value "1"
47 |
48 | Write-Host "`nBluebeam Updates has been Disabled.`n" -ForegroundColor Green
49 | Write-Host "`nClose and re-open Bluebeam for the changes to take effect.`n" -ForegroundColor Green
50 |
51 | $val = 1
52 |
53 | }
54 | 2 {
55 |
56 | Write-Host "Quit" -ForegroundColor Red
57 | $val = 2
58 | Exit
59 | }
60 | }
61 | }
62 |
63 |
64 | While($val -ne 2){
65 | UpdateSwitch
66 | }
--------------------------------------------------------------------------------
/Update-BatchFiles.ps1:
--------------------------------------------------------------------------------
1 | $logfile = "C:\Temp\PrinterError.log"
2 | $sourceFolder = "C:\Users\rcurran\Turner Construction\Information Services - Turner Printers"
3 |
4 | function Log-Error {
5 | param(
6 | [string]$errorMessage
7 | )
8 | $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
9 | $logMessage = "$timestamp - Error: $errorMessage"
10 | Add-Content -Path $logfile -Value $logMessage
11 | }
12 |
13 | # Get all subfolders in the source folder
14 | $subFolders = Get-ChildItem $sourceFolder -Directory -Recurse
15 |
16 | # Extract all .zip files and delete them
17 | foreach ($subFolder in $subFolders) {
18 | $zipFiles = Get-ChildItem $subFolder.FullName -Filter "*.zip"
19 | foreach ($zipFile in $zipFiles) {
20 | try {
21 | $destinationFolder = Join-Path $subFolder.FullName ($zipFile.BaseName)
22 | if (!(Test-Path $destinationFolder)) {
23 | New-Item -ItemType Directory -Path $destinationFolder | Out-Null
24 | }
25 | "Expanding $($zipfile.Fullname)"
26 | Expand-Archive -Path $zipFile.FullName -DestinationPath $destinationFolder -Force
27 | Remove-Item -Path $zipFile.FullName -Force
28 | } catch {
29 | # Catch the error and log it
30 | $errorMessage = $_.Exception.Message
31 | Log-Error -errorMessage $errorMessage
32 | Write-Output "An error occurred: $errorMessage"
33 | }
34 | }
35 | }
36 |
37 | # Search and replace text in .bat files
38 | $batFiles = Get-ChildItem $sourceFolder -Filter "*.bat" -Recurse
39 | foreach ($batFile in $batFiles) {
40 | try {
41 | $content = Get-Content $batFile.FullName
42 | $newContent = $content -ireplace "alnfile1\\Software", "tcco.org\tccofile1\Software"
43 | Set-Content $batFile.FullName $newContent
44 | "Updating $batFile.FullName to point to tccofile1"
45 |
46 | # Create a .zip file for the .bat file
47 | $folderName = Split-Path $batFile.DirectoryName -Leaf
48 | $zipFileName = Join-Path $batFile.Directory.Parent.FullName ($folderName + ".zip")
49 | "Creating $zipFileName"
50 | Compress-Archive -Path $batFile.FullName -DestinationPath $zipFileName
51 |
52 | # Delete the folder containing the .bat file
53 | $folderToDelete = $batFile.DirectoryName
54 | Remove-Item -Path $folderToDelete -Recurse -Force
55 | } catch {
56 | # Catch the error and log it
57 | $errorMessage = $_.Exception.Message
58 | Log-Error -errorMessage $errorMessage
59 | Write-Output "An error occurred: $errorMessage"
60 | }
61 | }
62 |
63 | Write-Output "Script finished."
64 |
--------------------------------------------------------------------------------
/Development/Fileshare-Rename-Test.ps1:
--------------------------------------------------------------------------------
1 | #readd _Archive after testing
2 | $UDList = Get-childitem -Path "\\usnjfs001\H$" -exclude Batch,Kioware$,rcurran,jbilotti,rraia,vmarzarella #Readd _Archive
3 |
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 $UDList){
12 |
13 | $i++
14 |
15 | Write-Progress -Activity "Getting NTFS Permissions" -Status "Processing: $i of $($UDList.Count)"
16 |
17 | #isolate the original owners name / permissions
18 | $Accounts = Get-Ntfsaccess -Path "\\usnjfs001\h$\$($udl.name)" | Where-object{$_.Account -notlike "*Admins" `
19 | -and $_.Account -notlike "S-1*" `
20 | -and $_.Account -notlike "*pa-*" `
21 | -and $_.Account -notlike "*Users*" `
22 | -and $_.Account -notlike "NT Authority*" `
23 | -and $_.Account -notlike "BUILTIN*" `
24 | -and $_.Account -notlike "*rcurran" `
25 | -and $_.Account -notlike "*jbilotti" `
26 | -and $_.Account -notlike "*CREATOR*" `
27 | -and $_.IsInherited -ne $True
28 | }
29 |
30 | #Permissions to restore
31 | $Accounts2 = Get-Ntfsaccess -Path "\\usnjfs001\h$\_Archive\$($udl.name)"
32 | $Accounts3 = @("Medline-NT\Domain Admins", "Medline-NT\Excelsior Admins","Builtin\Administrators")
33 |
34 | #Turn make the account name without Medline-NT\
35 | $AccNR = $Accounts.Account.accountname -replace [Regex]::Escape('Medline-nt\'),"" | Where-object{$_ -ne ""}
36 |
37 | #Add a header and the hidden share $ after the accountname
38 | $AccountNameReplace = $AccNR | Select-Object @{Name = "AccountName" ; Expression = {$AccNR}}
39 | $ANRhidden = "$($Accountnamereplace.accountname)" + '$'
40 |
41 | #rename folder to match AD name then share it
42 | "Renaming $($UDL.Fullname) to $($Accountnamereplace.accountname)"
43 | Rename-Item -Path $UDL.FullName -Newname "$($UDL.Root)\$($UDL.Parent)\$($AccountNameReplace.AccountName)"
44 | "Sharing $($Accountnamereplace.accountname) with the name $ANRHidden"
45 | New-SMBShare -Name $ANRhidden -Path "H:\_Archive\$($AccountNameReplace.AccountName)" -Fullaccess $fullaccess -Cimsession $Session
46 |
47 |
48 | ForEach($Acc2 in $Accounts2){
49 |
50 | #Add the accounts from the old folder
51 | Write-host "Adding $($Acc2.AccessRights) for $Acc2 to $($Accountnamereplace.Accountname)" -ForegroundColor Green
52 | Add-NTFSACCESS -Path "$($UDL.Root)\$($UDL.Parent)\$($AccountNameReplace.AccountName)" -Account $Acc2.Account -AccessRights $Acc2.AccessRights
53 |
54 | }
55 | }
56 |
57 | Remove-Cimsession -cimsession $Session
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Disable-CredentialGuard.ps1:
--------------------------------------------------------------------------------
1 | # Real registry update function with logging
2 | function Set-RegistryValue {
3 | param (
4 | [string]$Path,
5 | [string]$Name,
6 | [int]$Value,
7 | [string]$Description
8 | )
9 |
10 | if (-not (Test-Path $Path)) {
11 | $message = "$Description path does not exist: $Path. Key will not be created automatically."
12 | Write-EventLog -LogName Application -Source "CredentialGuardScript" -EntryType Warning -EventId 1004 -Message $message
13 | Write-Host $message -ForegroundColor DarkYellow
14 | return
15 | }
16 |
17 | try {
18 | $currentValue = (Get-ItemProperty -Path $Path -Name $Name -ErrorAction Stop).$Name
19 | if ($currentValue -eq $Value) {
20 | $message = "$Description already set to $Value in registry path: $Path"
21 | Write-EventLog -LogName Application -Source "CredentialGuardScript" -EntryType Information -EventId 1003 -Message $message
22 | Write-Host $message -ForegroundColor Cyan
23 | } else {
24 | Set-ItemProperty -Path $Path -Name $Name -Value $Value -ErrorAction Stop
25 | $message = "$Description updated to $Value in registry path: $Path"
26 | Write-EventLog -LogName Application -Source "CredentialGuardScript" -EntryType Information -EventId 1000 -Message $message
27 | Write-Host $message -ForegroundColor Green
28 | }
29 | } catch {
30 | $errorMsg = "$Description failed to update in registry path: $Path. Error: $($_.Exception.Message)"
31 | Write-EventLog -LogName Application -Source "CredentialGuardScript" -EntryType Error -EventId 1001 -Message $errorMsg
32 | Write-Host $errorMsg -ForegroundColor Red
33 | }
34 | }
35 |
36 | # Ensure the event source exists
37 | if (-not [System.Diagnostics.EventLog]::SourceExists("CredentialGuardScript")) {
38 | New-EventLog -LogName Application -Source "CredentialGuardScript"
39 | }
40 |
41 | # Apply registry changes
42 | Set-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "LsaCfgFlags" -Value 0 -Description "Credential Guard (SYSTEM)"
43 | Set-RegistryValue -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard" -Name "LsaCfgFlags" -Value 0 -Description "Credential Guard (SOFTWARE)"
44 | Set-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard" -Name "EnableVirtualizationBasedSecurity" -Value 0 -Description "Virtualization-based Security"
45 |
46 | # Final restart notification
47 | $restartMsg = "Credential Guard settings have been updated or confirmed. A restart is required for changes to take effect."
48 | Write-EventLog -LogName Application -Source "CredentialGuardScript" -EntryType Information -EventId 1002 -Message $restartMsg
49 | Write-Host $restartMsg -ForegroundColor Yellow
50 |
--------------------------------------------------------------------------------
/Disable-AdapterWarningDell.ps1:
--------------------------------------------------------------------------------
1 | Function Check-RunAsAdministrator()
2 | {
3 | #Get current user context
4 | $CurrentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
5 |
6 | #Check user is running the script is member of Administrator Group
7 | if($CurrentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator))
8 | {
9 | Write-host "Script is running with Administrator privileges!" -ForegroundColor DarkGreen
10 | }
11 | else
12 | {
13 | #Create a new Elevated process to Start PowerShell
14 | $ElevatedProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell";
15 |
16 | # Specify the current script path and name as a parameter
17 | $ElevatedProcess.Arguments = "& '" + $script:MyInvocation.MyCommand.Path + "'"
18 |
19 | #Set the Process to elevated
20 | $ElevatedProcess.Verb = "runas"
21 |
22 | #Start the new elevated process
23 | [System.Diagnostics.Process]::Start($ElevatedProcess)
24 |
25 | #Exit from the current, unelevated, process
26 | Exit
27 |
28 | }
29 | }
30 |
31 | #Check Script is running with Elevated Privileges
32 | Check-RunAsAdministrator
33 |
34 | if(Get-Module -ListAvailable -name DellBIOSProvider){
35 | "------------------------------------------------------`n"
36 | Write-host "Module Installed, skipping install sequence" -ForegroundColor Green
37 | Start-sleep -Seconds 1
38 | "------------------------------------------------------`n"
39 | }else{
40 | "------------------------------------------------------`n"
41 | Write-Host "DellBIOSProvider Module not installed, installing now.`n" -ForegroundColor Yellow
42 | "------------------------------------------------------`n"
43 | Install-Module -Name DellBIOSProvider -Confirm -Force
44 | Write-host "DellBiosProvider Module has been installed.`n"
45 | "------------------------------------------------------`n"
46 | Start-sleep -Seconds 1
47 | }
48 |
49 | Write-Host "Importing Module DellBiosProvider `n" -ForegroundColor Green
50 | "------------------------------------------------------`n"
51 | Import-Module DellBiosProvider
52 |
53 | $power = Get-item DellSMBios:\POSTBehavior\PowerWarn
54 |
55 | if($power.CurrentValue -eq "Disabled"){
56 | $power
57 | Write-Host "Power Adapter Warning Is Already Disabled.`n"
58 | "Nothing has been changed."
59 | }else{
60 | $power
61 | Write-host "Disabling Adapter Warning `n" -ForegroundColor Green
62 | set-Item DellSMBios:\POSTBehavior\PowerWarn "Disabled"
63 | Get-item DellSMBios:\POSTBehavior\PowerWarn
64 | Start-sleep -Seconds 1
65 | Write-host "Adapter Warning has been Disabled `n" -ForegroundColor Green
66 | "------------------------------------------------------`n"
67 | }
68 |
69 | pause
--------------------------------------------------------------------------------
/Printer batch files update.ps1:
--------------------------------------------------------------------------------
1 | $logfile = "C:\Temp\PrinterError.log"
2 | $sourceFolder = "C:\Users\rcurran\Turner Construction\Information Services - Turner Printers"
3 | #$sourceFolder = "C:\temp\Fresno\"
4 |
5 |
6 | function Log-Error {
7 | param(
8 | [string]$errorMessage
9 | )
10 | $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
11 | $logMessage = "$timestamp - Error: $errorMessage"
12 | Add-Content -Path $logfile -Value $logMessage
13 | }
14 |
15 | # Get all subfolders in the source folder
16 | $subFolders = Get-ChildItem $sourceFolder -Directory -Recurse
17 |
18 | # Extract all .zip files and delete them
19 | foreach ($subFolder in $subFolders) {
20 | $zipFiles = Get-ChildItem $subFolder.FullName -Filter "*.zip"
21 | foreach ($zipFile in $zipFiles) {
22 | try {
23 | $destinationFolder = Join-Path $subFolder.FullName ($zipFile.BaseName)
24 | if (!(Test-Path $destinationFolder)) {
25 | New-Item -ItemType Directory -Path $destinationFolder | Out-Null
26 | }
27 | "Expanding $($zipfile.Fullname)"
28 | Expand-Archive -Path $zipFile.FullName -DestinationPath $destinationFolder -Force
29 | Remove-Item -Path $zipFile.FullName -Force
30 | } catch {
31 | # Catch the error and log it
32 | $errorMessage = $_.Exception.Message
33 | Log-Error -errorMessage $errorMessage
34 | Write-Output "An error occurred: $errorMessage"
35 | }
36 | }
37 | }
38 |
39 | # Search and replace text in .bat files
40 | $batFiles = Get-ChildItem $sourceFolder -Filter "*.bat" -Recurse
41 | foreach ($batFile in $batFiles) {
42 | try {
43 | $content = Get-Content $batFile.FullName
44 | $newContent = $content -ireplace "alnfile1\\Software", "tcco.org\tccofile1\Software"
45 | $newContent = $content -ireplace 'set "tcco.org"', 'set "host=tcco.org"'
46 | $newContent = $content -ireplace "tcco.org\\Software", 'tcco.org\tccofile1\Software'
47 | Set-Content $batFile.FullName $newContent
48 | "Updating $batFile.FullName to point to tccofile1"
49 |
50 | # Create a .zip file for the .bat file
51 | $folderName = Split-Path $batFile.DirectoryName -Leaf
52 | $zipFileName = Join-Path $batFile.Directory.Parent.FullName ($folderName + ".zip")
53 | "Creating $zipFileName"
54 | Compress-Archive -Path $batFile.FullName -DestinationPath $zipFileName
55 |
56 | # Delete the folder containing the .bat file
57 | $folderToDelete = $batFile.DirectoryName
58 | Remove-Item -Path $folderToDelete -Recurse -Force
59 | } catch {
60 | # Catch the error and log it
61 | $errorMessage = $_.Exception.Message
62 | Log-Error -errorMessage $errorMessage
63 | Write-Output "An error occurred: $errorMessage"
64 | }
65 | }
66 |
67 | Write-Output "Script finished."
68 |
--------------------------------------------------------------------------------
/Disable-IPv6_All_Adapters.ps1:
--------------------------------------------------------------------------------
1 | Function Check-RunAsAdministrator()
2 | {
3 | #Get current user context
4 | $CurrentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
5 |
6 | #Check user is running the script is member of Administrator Group
7 | if($CurrentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator))
8 | {
9 | Write-host "Script is running with Administrator privileges!"
10 | }
11 | else
12 | {
13 | #Create a new Elevated process to Start PowerShell
14 | $ElevatedProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell";
15 |
16 | # Specify the current script path and name as a parameter
17 | $ElevatedProcess.Arguments = "& '" + $script:MyInvocation.MyCommand.Path + "'"
18 |
19 | #Set the Process to elevated
20 | $ElevatedProcess.Verb = "runas"
21 |
22 | #Start the new elevated process
23 | [System.Diagnostics.Process]::Start($ElevatedProcess)
24 |
25 | #Exit from the current, unelevated, process
26 | Exit
27 |
28 | }
29 | }
30 |
31 | #Check Script is running with Elevated Privileges
32 | Check-RunAsAdministrator
33 |
34 |
35 | $Adapter = Get-NetAdapterBinding |where-Object ComponentID -EQ 'ms_tcpip6' | Where-Object Name -notlike "*Bluetooth*"
36 | "Adapters Loaded`n"
37 | $Val = 1
38 | function AdapterSwitch{
39 | $Title = "Choose options 1, 2 or 3 to proceed."
40 | $Info = Write-host "Would you like to enable or disable IPv6 on all adapters?" -Foregroundcolor Yellow -Backgroundcolor Black
41 |
42 | $options = [System.Management.Automation.Host.ChoiceDescription[]] @("&1. Enable", "&2. Disable", "&3. Quit")
43 | [int]$defaultchoice = 1
44 | $opt = $host.UI.PromptForChoice($Title, $Info , $Options,$defaultchoice)
45 | switch($opt)
46 | {
47 | 0 {
48 |
49 | Write-Host "Enable IPv6" -ForegroundColor Green
50 |
51 | Foreach ($Adapt in $Adapter){
52 |
53 | Enable-netadapterbinding -Name $adapt.name -ComponentID 'ms_tcpip6'
54 | "Enabling $($Adapt.name)'s IPv6"
55 | }
56 | "`nIPv6 has been disabled from $($Adapter.Count) adapters.`n"
57 | $val = 0
58 |
59 | }
60 | 1 {
61 |
62 | Write-Host "Disable IPv6" -ForegroundColor Green
63 |
64 | Foreach ($Adapt in $Adapter){
65 |
66 | Disable-netadapterbinding -Name $adapt.name -ComponentID 'ms_tcpip6'
67 | "Disabling $($Adapt.name)'s IPv6"
68 | }
69 | "`nIPv6 has been disabled from $($Adapter.Count) adapters.`n"
70 | $val = 1
71 |
72 | }
73 | 2 {
74 |
75 | Write-Host "Quit" -ForegroundColor Red
76 | $val = 2
77 | Exit
78 | }
79 | }
80 | }
81 |
82 | While($val -ne 2){
83 | AdapterSwitch
84 | }
--------------------------------------------------------------------------------
/Report-MFAEnrollment.ps1:
--------------------------------------------------------------------------------
1 | if (-not (Get-Module -ListAvailable -Name ImportExcel)) {
2 | Write-Host "ImportExcel module not found. Installing..."
3 | Install-Module -Name ImportExcel -Scope CurrentUser -Force
4 | } else {
5 | Write-Host "ImportExcel module is already installed."
6 | }
7 |
8 | Import-Module ImportExcel
9 | import-module activedirectory
10 |
11 | $OUS = @(
12 | #'OU=Users,OU=New Jersey,OU=North East,OU=Offices,DC=tcco,DC=org'
13 | #'OU=Users,OU=Albany,OU=North East,OU=Offices,DC=tcco,DC=org'
14 | #'OU=Users,OU=Buffalo,OU=North East,OU=Offices,DC=tcco,DC=org'
15 | #'OU=Users,OU=Philadelphia,OU=North Central,OU=Offices,DC=tcco,DC=org'
16 | #'OU=Users,OU=Pittsburgh,OU=North Central,OU=Offices,DC=tcco,DC=org'
17 | #'OU=Users,OU=Mahwah,OU=North East,OU=Offices,DC=tcco,DC=org'
18 | 'OU=Users,OU=TSIB,OU=North East,OU=Offices,DC=tcco,DC=org'
19 | )
20 |
21 | #Establish variables and arrays
22 | $OURegex = [String]::Join('|',$OUS)
23 | $mfanew = @()
24 | $usernew= @()
25 | $mfaArray= @()
26 | $userIn = @()
27 | $userIn1 = @()
28 | $userEx = @()
29 |
30 | #Get List of group members for MDM
31 | #$mfa = get-adgroupmember -Identity TUR.ALL.MFA.USERS
32 | Write-host "Getting TUR.ALL.MFA.USERS Group`n" -ForegroundColor Green
33 | $mfa = get-adgroup -Identity TUR.ALL.MFA.USERS -Properties Member | Select-Object -ExpandProperty Member | Get-ADUser -Property Name, Displayname
34 |
35 | #Foreach user object in $MDM, check to see if their distinguished name has one of the OUs, If $True run a Get-ADuser search and save to $mdmNew
36 | "Processing the MFA User Group to regex the group membership"
37 | Foreach($m in $mfa){
38 | if($m.DistinguishedName -match $OURegex){
39 | "Running Regex on $($M.Displayname)"
40 | $mfaArray = get-aduser -identity $m.samaccountname -properties displayname | select Displayname
41 | $mfaNew += $mfaArray
42 | $mFaArray
43 | }else{
44 |
45 | }
46 | }
47 |
48 |
49 | #Foreach OU from $OUs list to get the comparison array then compare it against mdmNew and export to excel PANJMDMUsers for two categories, completed and not enrolled.
50 | ForEach($OU in $OUs){
51 | Write-host "Running for $OU" -ForegroundColor Green
52 | $Users = Get-aduser -SearchBase $OU -Filter * -properties Displayname | Select displayName
53 | $userIn = Compare-Object -DifferenceObject $users.displayname -ReferenceObject $mfaNew.displayname -IncludeEqual -ExcludeDifferent
54 | $userIn1 += $userIn
55 | $userEx = Compare-Object -DifferenceObject $users.displayname -ReferenceObject $mfaNew.displayname
56 | $userEx | export-excel -WorksheetName "Not Enrolled" -path C:\temp\PANJMFAUsers-$([DateTime]::Now.ToSTring("MM-dd-yyyy")).xlsx -Append -Autosize -Title "Not yet Enrolled" -Autofilter
57 |
58 | }
59 |
60 | $userIn1 | export-excel -Worksheetname "Enrolled" -path C:\Temp\PANJMFAUsers-$([DateTime]::Now.ToSTring("MM-dd-yyyy")).xlsx -Append -Autosize -Title "Enrolled" -Autofilter
61 |
--------------------------------------------------------------------------------
/IPv6_Switch-All_Adapters.ps1:
--------------------------------------------------------------------------------
1 | Function Check-RunAsAdministrator()
2 | {
3 | #Get current user context
4 | $CurrentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
5 |
6 | #Check user is running the script is member of Administrator Group
7 | if($CurrentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator))
8 | {
9 | Write-host "Script is running with Administrator privileges!"
10 | }
11 | else
12 | {
13 | #Create a new Elevated process to Start PowerShell
14 | $ElevatedProcess = New-Object System.Diagnostics.ProcessStartInfo "PowerShell";
15 |
16 | # Specify the current script path and name as a parameter
17 | $ElevatedProcess.Arguments = "& '" + $script:MyInvocation.MyCommand.Path + "'"
18 |
19 | #Set the Process to elevated
20 | $ElevatedProcess.Verb = "runas"
21 |
22 | #Start the new elevated process
23 | [System.Diagnostics.Process]::Start($ElevatedProcess)
24 |
25 | #Exit from the current, unelevated, process
26 | Exit
27 |
28 | }
29 | }
30 |
31 | #Check Script is running with Elevated Privileges
32 | Check-RunAsAdministrator
33 |
34 | #Place your script here.
35 |
36 | $Adapter = Get-NetAdapterBinding |where-Object ComponentID -EQ 'ms_tcpip6' | Where-Object Name -notlike "*Bluetooth*"
37 | "Adapters Loaded`n"
38 | $Val = 1
39 | function AdapterSwitch{
40 | $Title = "Choose options 1, 2 or 3 to proceed."
41 | $Info = Write-host "Would you like to enable or disable IPv6 on all adapters?" -Foregroundcolor Yellow -Backgroundcolor Black
42 |
43 | $options = [System.Management.Automation.Host.ChoiceDescription[]] @("&1. Enable", "&2. Disable", "&3. Quit")
44 | [int]$defaultchoice = 1
45 | $opt = $host.UI.PromptForChoice($Title, $Info , $Options,$defaultchoice)
46 | switch($opt)
47 | {
48 | 0 {
49 |
50 | Write-Host "Enable IPv6" -ForegroundColor Green
51 |
52 | Foreach ($Adapt in $Adapter){
53 |
54 | Enable-netadapterbinding -Name $adapt.name -ComponentID 'ms_tcpip6'
55 | "Enabling $($Adapt.name)'s IPv6"
56 | }
57 | "`nIPv6 has been disabled from $($Adapter.Count) adapters.`n"
58 | $val = 0
59 |
60 | }
61 | 1 {
62 |
63 | Write-Host "Disable IPv6" -ForegroundColor Green
64 |
65 | Foreach ($Adapt in $Adapter){
66 |
67 | Disable-netadapterbinding -Name $adapt.name -ComponentID 'ms_tcpip6'
68 | "Disabling $($Adapt.name)'s IPv6"
69 | }
70 | "`nIPv6 has been disabled from $($Adapter.Count) adapters.`n"
71 | $val = 1
72 |
73 | }
74 | 2 {
75 |
76 | Write-Host "Quit" -ForegroundColor Red
77 | $val = 2
78 | Exit
79 | }
80 | }
81 | }
82 |
83 | While($val -ne 2){
84 | AdapterSwitch
85 | }
--------------------------------------------------------------------------------
/Report-IntuneStaleDeviceID_v3-Parallel.ps1:
--------------------------------------------------------------------------------
1 | # Ensure the script runs in PowerShell 7+
2 | if ($PSVersionTable.PSVersion.Major -lt 7) {
3 | Write-Host "This script requires PowerShell 7 or higher." -ForegroundColor Red
4 | exit
5 | }
6 |
7 | Measure-Command {
8 | function Test-Admin {
9 | return ([bool]([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
10 | }
11 |
12 | # Function to restart the script with elevated privileges if not running as Admin
13 | function Elevate-Script {
14 | if (-not (Test-Admin)) {
15 | $arguments = "& '" + $myinvocation.mycommand.definition + "'"
16 | Start-Process powershell -ArgumentList $arguments -Verb RunAs
17 | exit
18 | }
19 | }
20 |
21 | # Function to install a module if it is not installed
22 | function Install-ModuleIfNotInstalled {
23 | param (
24 | [string]$ModuleName
25 | )
26 | if (-not (Get-Module -ListAvailable -Name $ModuleName)) {
27 | Write-Host "Installing module $ModuleName"
28 | Install-Module -Name $ModuleName -Force -Confirm:$false
29 | } else {
30 | Write-Host "Module $ModuleName is already installed"
31 | }
32 | }
33 |
34 | Elevate-Script
35 |
36 | # Load necessary modules
37 | Install-ModuleIfNotInstalled -ModuleName "WindowsCompatibility"
38 | Install-ModuleIfNotInstalled -ModuleName "Microsoft.Graph"
39 |
40 | Import-WinModule -Name ActiveDirectory
41 | # Connect to Microsoft Graph
42 | $ImpTenantID = Get-Content "C:\Users\rcurran\OneDrive - Turner Construction\Intune\IntuneTenantID.txt"
43 | Connect-MgGraph -TenantID "$ImpTenantID" -NoWelcome
44 |
45 | # Define CSV file path
46 |
47 | $CsvFile = "C:\temp\reports\Intune-StaleDeviceID-$([DateTime]::Now.ToString('MM-dd-yyyy-hh.mm')).csv"
48 |
49 | # Retrieve AD Organizational Units
50 | $CompOrgUnits = Get-ADOrganizationalUnit -Filter {Name -eq "Computers"} | Select-Object Name, DistinguishedName
51 |
52 | # Fetch all AD computer objects in parallel
53 | $ADPC = $CompOrgUnits | ForEach-Object {
54 | Get-ADComputer -SearchBase $_.DistinguishedName -Filter {
55 | (Enabled -eq $True) -and (Description -notlike "*Server*")
56 | } | Select-Object Name, ObjectGUID
57 | }
58 |
59 | Foreach-object -Parallel ($PC in $ADPC){
60 |
61 | $MSDev = Get-MGDevice -Filter "DisplayName eq '$($PC.Name)'" | Select-Object DisplayName, DeviceID
62 |
63 | foreach ($Dev in $MSDev) {
64 | $CrossMatch = ($Dev.DeviceID -eq $PC.ObjectGUID)
65 |
66 | $Result = [PSCustomObject]@{
67 | "Device Name" = $PC.Name
68 | "Device GUID" = $PC.ObjectGUID
69 | "Intune DeviceID" = $Dev.DeviceID
70 | "Cross Match" = $CrossMatch
71 | }
72 |
73 | # Append to CSV
74 | $Result | Export-Csv -Path $CsvFile -NoTypeInformation -Append
75 | }
76 | }
77 |
78 | }
--------------------------------------------------------------------------------
/CopyAdd-WifiProfile.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 | $i = 0
26 |
27 | Write-Host "Select the Shortcut to Transfer" -ForegroundColor Green
28 | #Use Function to Get the File to transfer
29 | $FileToTransfer = Get-FileName
30 |
31 | Write-host "Select the List of Computers to transfer the shortcut to" -ForegroundColor Green
32 | #Use Function to Get the CSV list of Computers
33 | $Comps = Get-FileName
34 |
35 | #Convert $Comps to CSV and assign it to $PCS
36 | $PCS = Import-CSV $Comps
37 |
38 | Write-Host "You Selected the Path $XML" -ForegroundColor Green
39 |
40 | #Run a ForEach on each hostname in $PCs Assign it to $PC
41 | ForEach($PC in $PCs){
42 | #Increment $i from 0 to get a count
43 | $i++
44 | #Show progress of the count
45 | Write-Progress -Activity "Installing new MEDLINE SSID" -Status "Installed: $i of $($PCs.count)"
46 |
47 | Write-Host "Testing $($PC.Hostname) for Activity" -ForegroundColor Green
48 | #Test each computer and assign the value to $tp if it returns $True, run the script, if not export an error to an error log
49 | $tp = Test-Connection -ComputerName $PC.Hostname -quiet -Count 1
50 |
51 | if($tp -eq $True){
52 | #Write-Host "I AM ONLINE $($PC.Hostname)"
53 | Write-Host "Copying to $($PC.Hostname)" -ForegroundColor Green
54 |
55 | #Copy the file to the remote computer
56 | xcopy $FileToTransfer "\\$($PC.Hostname)\C$\"
57 |
58 | #setup remote session to the current PC in the list
59 | PsExec64.exe "\\$($PC.Hostname)" powershell.exe
60 |
61 | #remote execute the netsh add for the wireless profile
62 | "netsh wlan add profile filename=C:\MEDLINE.xml User=All"
63 | #remote execute the deletion of the wireless profile
64 | "netsh wlan delete profile name=excmed"
65 |
66 | #end session
67 | Exit
68 |
69 | }else{
70 | Write-Host "$($PC.Hostname) Is Unavailable" -ForegroundColor Red
71 | $PC | Select @{Name = "Hostname"; Expression = {$($PC.Hostname)}} | Export-csv C:\CSV\FailedHostnames.csv -Append -Notypeinformation
72 |
73 | }
74 | }
75 |
76 |
--------------------------------------------------------------------------------
/Report-FilesharePermissions.ps1:
--------------------------------------------------------------------------------
1 | # ExportShareInfo.ps1
2 | # This script will export type 0 shares with security info, and provide a hash table of shares
3 | # in which security info could not be found.
4 | #
5 | #reference: http://mow001.blogspot.com/2006/05/powershell-export-shares-and-security.html
6 | #SID was removed from the script. Instead, the username is used to find SID when the import is run
7 |
8 | # CHANGE TO SERVER THAT HAS SHARES TO EXPORT
9 | $fileServer = "USNJFS001"
10 |
11 | $date = get-date
12 | $datefile = get-date -uformat '%m-%d-%Y-%H%M%S'
13 | $filename = 'USNJFS001-Groups-Permissions.csv'
14 | #Store shares where security cant be found in this hash table
15 | $problemShares = @{}
16 |
17 | Function Get-ShareInfo($shares) {
18 | $arrShareInfo = @()
19 | Foreach ($share in $shares) {
20 | trap{continue;}
21 | write-host $share.name"\\" +
22 | $strWMI = "\\" + $fileServer + "\root\cimv2:win32_LogicalShareSecuritySetting.Name='" + $share.name + "'"
23 | $objWMI_ThisShareSec = $null
24 | $objWMI_ThisShareSec = [wmi]$strWMI
25 |
26 | #In case the WMI query or 'GetSecurityDescriptor' fails, we retry a few times before adding to 'problem shares'
27 | For($i=0;($i -lt 5) -and ($objWMI_ThisShareSec -eq $null);$i++) {
28 | sleep -milliseconds 200
29 | $objWMI_ThisShareSec = [wmi]$strWMI
30 | }
31 | $objWMI_SD = $null
32 | $objWMI_SD = $objWMI_ThisShareSec.invokeMethod('GetSecurityDescriptor',$null,$null)
33 | For($j=0;($j -lt 5) -and ($objWMI_SD -eq $null);$j++) {
34 | sleep -milliseconds 200
35 | $objWMI_SD = $objWMI_ThisShareSec.invokeMethod('GetSecurityDescriptor',$null,$null)
36 | }
37 | If($objWMI_SD -ne $null) {
38 | $arrShareInfo += $objWMI_SD.Descriptor.DACL | % {
39 | $_ | select @{e={$share.name};n='Name'},
40 | @{e={$share.Path};n='Path'},
41 | @{e={$share.Description};n='Description'},
42 | AccessMask,
43 | AceFlags,
44 | AceType,
45 | @{e={$_.trustee.Name};n='User'},
46 | @{e={$_.trustee.Domain};n='Domain'}
47 | }
48 | }
49 | Else {
50 | $ProblemShares.Add($share.name, "failed to find security info")
51 | }
52 | }
53 | return $arrshareInfo
54 | }
55 |
56 | Write-Host "Finding Share Security Information"
57 |
58 | # get Shares (Type 0 is "Normal" shares) # can filter on path, etc. with where
59 | $shares = gwmi Win32_Share -computername $fileServer -filter 'USNJFS001\Groups'
60 |
61 | # get the security info from shares, add the objects to an array
62 | Write-Host " Complete" -ForegroundColor green
63 | Write-Host "Preparing Security Info for Export"
64 |
65 | $ShareInfo = Get-ShareInfo($shares)
66 |
67 | Write-Host " Complete" -ForegroundColor green
68 | Write-Host "Exporting to CSV"
69 |
70 | # Export them to CSV
71 | $ShareInfo | select Name,Path,Description,User,Domain,
72 | AccessMask,AceFlags,AceType | export-csv -noType $filename
73 |
74 | Write-Host " Complete" -ForegroundColor green
75 | Write-Host "Your file has been saved to $filename"
76 | If ($problemShares.count -ge 1) {
77 | Write-Host "These Shares Failed to Export:"
78 | }
79 | $problemShares
--------------------------------------------------------------------------------
/Report-ExpiringADPasswords-14Days.ps1:
--------------------------------------------------------------------------------
1 | # Import the Active Directory module
2 | Import-Module ActiveDirectory
3 |
4 | # Ensure the ImportExcel module is available
5 | if (-not (Get-Module -ListAvailable -Name ImportExcel)) {
6 | Install-Module -Name ImportExcel -Force -Scope CurrentUser
7 | Import-Module ImportExcel
8 | }
9 |
10 | # Define the threshold for password expiration (in days)
11 | $daysToExpire = 14
12 |
13 | # Calculate the date for the threshold
14 | $currentDate = Get-Date
15 | $thresholdDate = $currentDate.AddDays($daysToExpire)
16 |
17 | # Get the domain's password policy max age
18 | $passwordMaxAge = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge
19 |
20 | # Query all users in the domain
21 | Write-Host "Querying Active Directory for users..." -ForegroundColor Cyan
22 | $users = Get-ADUser -Filter {Enabled -eq $true} -Properties DisplayName, SamAccountName, PasswordLastSet, DistinguishedName
23 |
24 | # Total number of users for progress tracking
25 | $totalUsers = $users.Count
26 | $currentIndex = 0
27 |
28 | # Create an array to store users with expiring passwords
29 | $expiringUsers = @()
30 |
31 | # Process each user
32 | foreach ($user in $users) {
33 | # Increment progress index
34 | $currentIndex++
35 |
36 | # Display progress bar
37 | Write-Progress -Activity "Processing Users..." -Status "User $currentIndex of $totalUsers" -PercentComplete (($currentIndex / $totalUsers) * 100)
38 |
39 | # Skip users who have never set their password
40 | if (-not $user.PasswordLastSet) {
41 | continue
42 | }
43 |
44 | # Calculate the password expiration date
45 | $passwordExpirationDate = $user.PasswordLastSet + $passwordMaxAge
46 |
47 | # Extract the desired OU (e.g., "New Jersey") from the DistinguishedName
48 | $ouPattern = "(?<=,OU=)([^,]+)" # Regex to match the first OU
49 | $ouMatches = [regex]::Matches($user.DistinguishedName, $ouPattern)
50 | $userOU = if ($ouMatches.Count -ge 2) { $ouMatches[1].Value } else { "Unknown OU" }
51 |
52 | # Check if the password is expiring within the threshold
53 | if ($passwordExpirationDate -lt $thresholdDate -and $passwordExpirationDate -gt $currentDate) {
54 | $expiringUsers += [PSCustomObject]@{
55 | DisplayName = $user.DisplayName
56 | SamAccountName = $user.SamAccountName
57 | OrganizationalUnit = $userOU
58 | PasswordExpiration = $passwordExpirationDate
59 | }
60 | }
61 | }
62 |
63 | # Generate timestamp for file naming
64 | $timestamp = (Get-Date).ToString("yyyy-MM-dd_HH-mm")
65 |
66 | # Export the detailed report to an XLSX file with table style
67 | $reportPath = "C:\Reports\ExpiringPasswordsReport_$timestamp.xlsx"
68 | if (-not (Test-Path "C:\Reports")) {
69 | New-Item -Path "C:\Reports" -ItemType Directory -Force
70 | }
71 | $expiringUsers | Sort-Object PasswordExpiration | Export-Excel -Path $reportPath -WorksheetName "Detailed Report" -TableStyle Medium16 -AutoSize
72 | Write-Host "Detailed report generated: $reportPath" -ForegroundColor Green
73 |
--------------------------------------------------------------------------------
/Development/Percent-Change/Percent-Change/Percent-Change/Properties/Resources.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 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Percent_Change.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------