├── BATCH ├── WIP │ └── sharepoint │ │ └── moss2007 │ │ ├── AutomatedSharePoint2007FarmConfigurationBatchFile │ │ ├── Resource.txt │ │ └── psconfig.bat │ │ └── GaryLapointeSharePoint2007Install │ │ ├── InstallScript │ │ ├── Connect.bat │ │ ├── Lapointe.SharePoint.STSADM.Commands.wsp │ │ ├── install.bat │ │ ├── mysites.bat │ │ ├── portal.bat │ │ ├── teams.bat │ │ └── variables.bat │ │ └── Resource.txt └── Working │ ├── IIS │ └── GetAppPoolPassword.bat │ ├── SharePoint │ ├── InstallNewInfoPathFormTemplate.bat │ └── UpgradeInfoPathFormTemplate.bat │ └── System │ └── EmptyRecycleBin.bat ├── PowerShell └── Working │ ├── AD │ ├── AddADGroupMembersFromCSV.ps1 │ ├── CheckMaxTokenSize.ps1 │ ├── CompareADuserAddGroup.ps1 │ ├── Create-ADAccountsFromCSV.ps1 │ ├── CreateADUsersAndGroupsFromCSV.ps1 │ ├── GetADAccountLockedOutLocation.ps1 │ ├── GetADBitLockerRecovery.ps1 │ ├── GetADComputerInstalledKBsReport.ps1 │ ├── GetADExpiringUserAccountsReport.ps1 │ ├── GetADForestBackupHistory.ps1 │ ├── GetADForestHealthStatusReport.ps1 │ ├── GetADGroupManagedBy.ps1 │ ├── GetADGroupMembers.ps1 │ ├── GetADGroupModificationsReport.ps1 │ ├── GetADObjectsInAForest.ps1 │ ├── GetADOnlineMachines.ps1 │ ├── GetADReplicationStatusReportCSV.ps1 │ ├── GetADReplicationStatusReportHTML.ps1 │ ├── GetADUserPasswordLastSetReport.ps1 │ ├── GetADUserPropertiesToCSV.ps1 │ ├── GetADUserThumbnailPhotos.ps1 │ ├── GetRecentADUserAccounts.ps1 │ ├── GetRemoveAddADGroupMembers.ps1 │ ├── GetSPNRecordsInAD.ps1 │ ├── GetThumbnailPhotoSize.ps1 │ ├── GetTotalUsersGroupsContactsInForest.ps1 │ ├── GetUserPasswordLastSetDetails.ps1 │ ├── GetUsersLastLogonDateTime.ps1 │ ├── GetUsersLogonLogoffEvents.ps1 │ ├── InvokeADReplication.ps1 │ ├── MonitorADGroupMembershipModifications.ps1 │ ├── SetADAccountasLocalAdministrator.ps1 │ ├── UpdateADPhotos.ps1 │ ├── UserPasswordExpiryNotificationEmails.ps1 │ └── ValidateADUserCredential.ps1 │ ├── ADFS │ ├── ExportAndImportADFSClaimRules.ps1 │ ├── GetADFSReferenceNumberErrors.ps1 │ ├── SetMSOnlineFederationToADFS.ps1 │ ├── UpdateADFSTokenCerts.ps1 │ └── UsefulADFSCommands.ps1 │ ├── Azure │ ├── AzureADConnectCommunicationsTest.ps1 │ ├── AzureADConnectFullPasswordSync.ps1 │ ├── AzureADConnectGetADSyncServerConfiguration.ps1 │ ├── AzureADConnectGetConnectorSyncErrors.ps1 │ ├── AzureADConnectGetLocalSQLInstance.ps1 │ ├── AzureADConnectSetPreventAccidentalDeletes.ps1 │ ├── AzureADConnectStartSync.ps1 │ ├── AzureCloudShellCommands.ps1 │ ├── AzureGetAzureRMResourceReport.ps1 │ ├── AzureWebAppUploadFromLocalFolder.ps1 │ ├── AzureWebAppUploadFromStorageAccount.ps1 │ ├── ConnectToAzurePowerShellModules.ps1 │ ├── CreateAzureRmADApplication.ps1 │ ├── GetAzureRmADApplication.ps1 │ ├── GetAzureRmResourceGroupDeployment.ps1 │ └── InstallImportAzurePowerShell.ps1 │ ├── DNS │ ├── GetDNSRecordsForAllZones.ps1 │ └── UpdateDNSARecordIPAddress.ps1 │ ├── DPM │ ├── DPMGetDiskUtilizationReport.ps1 │ └── DPMGetRecoveryPointsReport.ps1 │ ├── DateTime │ └── GetDateFormatOptions.ps1 │ ├── DirSync │ ├── DirSyncSetPreventAccidentalDeletes.ps1 │ ├── DirSyncStartOnlineCoexistenceSync.ps1 │ └── DirSyncStatusReport.ps1 │ ├── Exchange │ ├── GetDistributionGroupMemberCounts.ps1 │ ├── GetDistributionGroupMemberReports.ps1 │ └── ManageDistributionGroups.ps1 │ ├── FIM │ └── ClearSynchronizationServiceManagerRunsHistory.ps1 │ ├── FTP │ ├── GetFTPDirectoryFiles.ps1 │ └── PSFTP │ │ ├── Add-FTPItem.ps1 │ │ ├── Get-FTPChildItem.ps1 │ │ ├── Get-FTPItem.ps1 │ │ ├── Get-FTPItemSize.ps1 │ │ ├── New-FTPItem.ps1 │ │ ├── PSFTP.Format.ps1xml │ │ ├── PSFTP.psd1 │ │ ├── PSFTP.psm1 │ │ ├── PowerShellFTPClientModule.txt │ │ ├── Readme.txt │ │ ├── Remove-FTPItem.ps1 │ │ ├── Rename-FTPItem.ps1 │ │ └── Set-FTPConnection.ps1 │ ├── Hyper-V │ └── PsHyperV │ │ ├── HyperV │ │ ├── En-us.ps1 │ │ ├── Helper.ps1 │ │ ├── HyperV.psd1 │ │ ├── MAML-VMNetwork.XML │ │ ├── MAML-VMSnapshot.XML │ │ ├── Maml-Helper.XML │ │ ├── Network.ps1 │ │ ├── SnapShot.ps1 │ │ ├── VMConfig.ps1 │ │ ├── disk.ps1 │ │ ├── hyperv.format.ps1xml │ │ ├── maml-vm.xml │ │ ├── maml-vmDisk.xml │ │ ├── maml-vmconfig.xml │ │ ├── menu.ps1 │ │ ├── v1Compatability.ps1 │ │ └── vm.ps1 │ │ ├── PS_Console.REG │ │ ├── PShyperv-R2.pdf │ │ ├── PsHyperV.txt │ │ └── install.cmd │ ├── IderaPowerShellScripts │ ├── Idera_ADPowerShellScripts │ │ ├── Add-IADGroupMember.ps1 │ │ ├── Disable-IADObject.ps1 │ │ ├── Disable-UserCannotChangePassword.ps1 │ │ ├── Enable-IADObject.ps1 │ │ ├── Enable-UserCannotChangePassword.ps1 │ │ ├── Get-IADAltRecipient.ps1 │ │ ├── Get-IADComputer.ps1 │ │ ├── Get-IADCurrentDomain.ps1 │ │ ├── Get-IADCurrentForest.ps1 │ │ ├── Get-IADDomainController.ps1 │ │ ├── Get-IADDomainController2.ps1 │ │ ├── Get-IADDomainPasswordPolicy.ps1 │ │ ├── Get-IADEmptyGroup.ps1 │ │ ├── Get-IADExchangeAdmin.ps1 │ │ ├── Get-IADFSMORoleHolder.ps1 │ │ ├── Get-IADGroup.ps1 │ │ ├── Get-IADGroupMember.ps1 │ │ ├── Get-IADGroupMembership.ps1 │ │ ├── Get-IADObjectBySID.ps1 │ │ ├── Get-IADObjectSID.ps1 │ │ ├── Get-IADSite.ps1 │ │ ├── Get-IADSubnet.ps1 │ │ ├── Get-IADTombstoneComputer.ps1 │ │ ├── Get-IADTombstoneObject.ps1 │ │ ├── Get-IADTombstoneUser.ps1 │ │ ├── Get-IADUser.ps1 │ │ ├── Move-IADObject.ps1 │ │ ├── New-IADGroup.ps1 │ │ ├── New-IADPassword.ps1 │ │ ├── New-IADUser.ps1 │ │ ├── Remove-IADGroupMember.ps1 │ │ ├── Remove-IADObject.ps1 │ │ └── Set-IADUser.ps1 │ ├── Idera_ExchangeScripts │ │ ├── Disable-IEXUser.ps1 │ │ ├── Get-IEXAvailableSpace.ps1 │ │ ├── Get-IEXClusterNode.ps1 │ │ ├── Get-IEXCurrentRole.ps1 │ │ ├── Get-IEXDatabaseQuotaStatistics.ps1 │ │ ├── Get-IEXDatabaseSize.ps1 │ │ ├── Get-IEXDatabaseStatistics.ps1 │ │ ├── Get-IEXEmailAddressOwner.ps1 │ │ ├── Get-IEXEmailAddressReport.ps1 │ │ ├── Get-IEXForwardMailbox.ps1 │ │ ├── Get-IEXInactiveMailbox.ps1 │ │ ├── Get-IEXLastSendAndReceivedDate.ps1 │ │ ├── Get-IEXMailboxAddressCount.ps1 │ │ ├── Get-IEXMailboxCountReport.ps1 │ │ ├── Get-IEXMailboxFolderStatistics.ps1 │ │ ├── Get-IEXMailboxStatistics.ps1 │ │ ├── Get-IEXSendAsPermission.ps1 │ │ ├── Get-IEXTip.ps1 │ │ ├── New-IEXAddressList.ps1 │ │ ├── New-IEXMailboxFromCsv.ps1 │ │ ├── New-IEXTestMailbox.ps1 │ │ ├── Purge-IEXMailbox.ps1 │ │ ├── Remove-IEXDisabledUser.ps1 │ │ ├── Set-IEXEmailAddress.ps1 │ │ ├── Test-IEXDistinguishedName.ps1 │ │ ├── Test-IEXEmailAddress.ps1 │ │ └── Test-IEXEmailAddress2.ps1 │ ├── Idera_PowerShellPlus │ │ ├── IderaPowerShellPlusInstallationKit-x64.zip │ │ └── IderaPowerShellPlusInstallationKit.zip │ ├── Idera_SQLServerScripts │ │ ├── SQL Server 2005 │ │ │ ├── Backup-SSAS.ps1 │ │ │ ├── CheckDB-MSSQL-UsingADO.ps1 │ │ │ ├── Connect-MSSQL-IPSQLAuth.ps1 │ │ │ ├── Connect-MSSQL-IPWindowsAuth.ps1 │ │ │ ├── Create-MSSQL-TestDb.ps1 │ │ │ ├── Create-MSSQLJob-UsingSMO.ps1 │ │ │ ├── CreateDB-MSSQL-UsingSMO.ps1 │ │ │ ├── CreateTable-MSSQL-UsingSMO.ps1 │ │ │ ├── Get-MSSQL-DB-UsingADO.ps1 │ │ │ ├── Get-MSSQL-DB-UsingSMO.ps1 │ │ │ ├── Get-MSSQL-MaxMemory.ps1 │ │ │ ├── Get-MSSQL-Port-UsingDMO.ps1 │ │ │ ├── Get-MSSQL-Port-UsingWMI.ps1 │ │ │ ├── Get-MSSQL-ServerAttrib-Csv.ps1 │ │ │ ├── Get-MSSQL-ServerAttrib-Html.ps1 │ │ │ ├── Get-MSSQL-ServerRegisterations.ps1 │ │ │ ├── Get-MSSQL-Views-Csv.ps1 │ │ │ ├── Insert-MSSQL-SampleData-Csv.ps1 │ │ │ ├── List-MSSQL-FailedJobs.ps1 │ │ │ ├── List-MSSQL-PropertyInfo.ps1 │ │ │ ├── Load-MSSQL-SMO.ps1 │ │ │ ├── Readme.doc │ │ │ ├── Readme.pdf │ │ │ ├── SampleData.csv │ │ │ ├── Start-SQLServerService.ps1 │ │ │ └── Stop-SQLServerService.ps1 │ │ └── SQL Server 2008 │ │ │ ├── Backup-SSAS.ps1 │ │ │ ├── CheckDB-MSSQL-UsingADO.ps1 │ │ │ ├── Connect-MSSQL-IPSQLAuth.ps1 │ │ │ ├── Connect-MSSQL-IPWindowsAuth.ps1 │ │ │ ├── Create-MSSQL-TestDb.ps1 │ │ │ ├── Create-MSSQLJob-UsingSMO.ps1 │ │ │ ├── CreateDB-MSSQL-UsingSMO.ps1 │ │ │ ├── CreateTable-MSSQL-UsingSMO.ps1 │ │ │ ├── Get-MSSQL-DB-UsingADO.ps1 │ │ │ ├── Get-MSSQL-DB-UsingSMO.ps1 │ │ │ ├── Get-MSSQL-MaxMemory.ps1 │ │ │ ├── Get-MSSQL-Port-UsingDMO.ps1 │ │ │ ├── Get-MSSQL-Port-UsingWMI.ps1 │ │ │ ├── Get-MSSQL-ServerAttrib-Csv.ps1 │ │ │ ├── Get-MSSQL-ServerAttrib-Html.ps1 │ │ │ ├── Get-MSSQL-ServerRegisterations.ps1 │ │ │ ├── Get-MSSQL-Views-Csv.ps1 │ │ │ ├── Insert-MSSQL-SampleData-Csv.ps1 │ │ │ ├── List-MSSQL-FailedJobs.ps1 │ │ │ ├── List-MSSQL-PropertyInfo.ps1 │ │ │ ├── Load-MSSQL-SMO.ps1 │ │ │ ├── Readme.doc │ │ │ ├── Readme.pdf │ │ │ ├── SampleData.csv │ │ │ ├── Start-SQLServerService.ps1 │ │ │ └── Stop-SQLServerService.ps1 │ └── Idera_SharePointScripts │ │ ├── Add-SPList.ps1 │ │ ├── Add-SPSite.ps1 │ │ ├── Add-SPUser.ps1 │ │ ├── CheckIn-SPDocument.ps1 │ │ ├── CheckOut-SPDocument.ps1 │ │ ├── Display-SPItemInformation.ps1 │ │ ├── Display-SPList.ps1 │ │ ├── Display-SPWebPart.ps1 │ │ ├── Export-SPSite.ps1 │ │ ├── Get-SPView.ps1 │ │ ├── Get-SPWeb.ps1 │ │ ├── Import-SPSite.ps1 │ │ ├── Readme.doc │ │ ├── Readme.pdf │ │ ├── Remove-SPList.ps1 │ │ ├── Remove-SPSite.ps1 │ │ └── Set-SPItem.ps1 │ ├── LogParser │ └── ProtocolStatusQuery.ps1 │ ├── MySQL │ └── MySQLRunQueryFunction.txt │ ├── NLB │ └── CreateNLBCluster.ps1 │ ├── PSRemoting │ ├── EnablePSRemoting.ps1 │ └── EncryptCredentialsForPSRemoting.ps1 │ ├── SQLServer │ ├── SQLClusterFailoverTest.ps1 │ ├── SQLPS │ │ ├── GetMAXDOP.ps1 │ │ ├── GetRecentFullDifferentialLogBackupHistory.ps1 │ │ ├── GetSQLConfigInfo.ps1 │ │ ├── GetSQLServerCores.ps1 │ │ ├── Readme.txt │ │ ├── SQLOutGridViewQueryFunction.ps1 │ │ └── SQLPowerShell.txt │ ├── SQLServerBackupHistoryReportWithHTML.ps1 │ ├── SQLServerCheckSharePointAccountsPermissions.ps1 │ ├── SQLServerConnectAndQueryDatabaseSizeAndGrowth.ps1 │ ├── SQLServerConnectAndRunQueries.ps1 │ ├── SQLServerConnectAndRunQueriesFromTextFile.ps1 │ ├── SQLServerConnectAndRunQueriesWithOutputs.ps1 │ ├── SQLServerGetDatabaseMailConfiguration.ps1 │ ├── SQLServerInstancesReport.ps1 │ ├── SQLServerInventoryReports.ps1 │ ├── SQLServerInventoryReportsWithDocsAndScripts.ps1 │ ├── SQLServerOutputAgentJobs.ps1 │ ├── SQLServerReorganizeOrRebuildIndexFragmentation.ps1 │ └── SQLServerResetAdminAccess.ps1 │ ├── ServiceNow │ └── ChangeMIDServerInstance.ps1 │ ├── SharePoint │ ├── MOSS2007 │ │ ├── GetSharePointOrphanedUsers.ps1 │ │ ├── SP2007AddListItemsFromCSVFile.ps1 │ │ ├── SP2007AddRemoveSiteCollectionAdmins.ps1 │ │ ├── SP2007CheckFarmPortsStatus.ps1 │ │ ├── SP2007CheckInDocuments.ps1 │ │ ├── SP2007CompareFilesAndFolders.ps1 │ │ ├── SP2007DeleteAllRecycleBinItems.ps1 │ │ ├── SP2007DeleteAuditDataTableRecords.ps1 │ │ ├── SP2007DeleteSPListItems.ps1 │ │ ├── SP2007DeleteSPListItemsPermanently.ps1 │ │ ├── SP2007DeleteUsersFromSites.ps1 │ │ ├── SP2007DisableDocumentParserProcessing.ps1 │ │ ├── SP2007EnumContentDatabases.ps1 │ │ ├── SP2007EnumFarmFunctions.ps1 │ │ ├── SP2007EnumFormTemplateLibraries.ps1 │ │ ├── SP2007EnumNavigationLinks.ps1 │ │ ├── SP2007EnumSiteGroups.ps1 │ │ ├── SP2007EnumSubSitesSizeInASiteCollection.ps1 │ │ ├── SP2007EnumUserProfileProperties.ps1 │ │ ├── SP2007EnumWorkFlows.ps1 │ │ ├── SP2007EnumerateListItems.ps1 │ │ ├── SP2007ExportSingleSolutionsFromSolutionStore.ps1 │ │ ├── SP2007ExtractDocLibraryToDisk.ps1 │ │ ├── SP2007FixUpgradeIssues.ps1 │ │ ├── SP2007GetAllFeaturesOnFilePath.ps1 │ │ ├── SP2007GetContentTypeQueries.ps1 │ │ ├── SP2007GetCrawlSchedules.ps1 │ │ ├── SP2007GetCredentialsAndPasswords.ps1 │ │ ├── SP2007GetDocInventory.ps1 │ │ ├── SP2007GetDocLibraryInventory.ps1 │ │ ├── SP2007GetFarmID.ps1 │ │ ├── SP2007GetSPFarmInventory.ps1 │ │ ├── SP2007GetSiteInventory.ps1 │ │ ├── SP2007GetUserProfileDetails.ps1 │ │ ├── SP2007HideListField.ps1 │ │ ├── SP2007HideListFieldLoop.ps1 │ │ ├── SP2007MigrateSiteCollections.ps1 │ │ ├── SP2007MigrateUser.ps1 │ │ ├── SP2007MonitorDiagnosticLogs.ps1 │ │ ├── SP2007MonitorWebAppAvailability.ps1 │ │ ├── SP2007SearchULSTraceLogs.ps1 │ │ ├── SP2007SetBinPathToEnvironmentVariables.ps1 │ │ ├── SP2007SetLibraryVersioningSettings.ps1 │ │ ├── SP2007ShowListFields.ps1 │ │ ├── SP2007TestNetworkLatency.ps1 │ │ ├── SP2007UpdateListField.ps1 │ │ ├── SP2007UpdateRequestAccessEmail.ps1 │ │ ├── SP2007UploadFilesFromFolder.ps1 │ │ ├── SP2007VersionSizeReport.ps1 │ │ ├── SP2007WarmUpEntireFarm.ps1 │ │ ├── SP2007WarmUpSpecificURLs.ps1 │ │ └── powershell.nu_moss2007_script_collection │ │ │ ├── Add-SPAnnouncement.ps1 │ │ │ ├── Add-SPCalendar.ps1 │ │ │ ├── Add-SPChoiceField.ps1 │ │ │ ├── Add-SPCurrencyField.ps1 │ │ │ ├── Add-SPDateTimeField.ps1 │ │ │ ├── Add-SPFieldToView.ps1 │ │ │ ├── Add-SPFolder.ps1 │ │ │ ├── Add-SPGroup.ps1 │ │ │ ├── Add-SPImageWebPart.ps1 │ │ │ ├── Add-SPLink.ps1 │ │ │ ├── Add-SPList.ps1 │ │ │ ├── Add-SPListToQuickLaunch.ps1 │ │ │ ├── Add-SPListViewWebPart.ps1 │ │ │ ├── Add-SPLookupField.ps1 │ │ │ ├── Add-SPMultiChoiceField.ps1 │ │ │ ├── Add-SPMultiLookupField.ps1 │ │ │ ├── Add-SPMultipleUserField.ps1 │ │ │ ├── Add-SPNoteField.ps1 │ │ │ ├── Add-SPNumberField.ps1 │ │ │ ├── Add-SPSite.ps1 │ │ │ ├── Add-SPSitePermission.ps1 │ │ │ ├── Add-SPTextField.ps1 │ │ │ ├── Add-SPURLField.ps1 │ │ │ ├── Add-SPUser.ps1 │ │ │ ├── Add-SPUserField.ps1 │ │ │ ├── Add-SPYesNoField.ps1 │ │ │ ├── Export-SPSite.ps1 │ │ │ ├── Get-SPField.ps1 │ │ │ ├── Get-SPItem.ps1 │ │ │ ├── Get-SPList.ps1 │ │ │ ├── Get-SPSite.ps1 │ │ │ ├── Get-SPView.ps1 │ │ │ ├── Get-SPWeb.ps1 │ │ │ ├── Import-SPSite.ps1 │ │ │ ├── Readme.txt │ │ │ ├── Remove-SPField.ps1 │ │ │ ├── Remove-SPItem.ps1 │ │ │ ├── Remove-SPList.ps1 │ │ │ ├── Remove-SPSite.ps1 │ │ │ ├── Set-SPImageWebPart.ps1 │ │ │ ├── Set-SPItem.ps1 │ │ │ ├── Set-SPQuickLaunchOrder.ps1 │ │ │ ├── Set-SPTheme.ps1 │ │ │ ├── Set-SPView.ps1 │ │ │ ├── Upload-SPDocument.ps1 │ │ │ └── powershell.nu_moss2007_script_collection.txt │ ├── SharePoint2010 │ │ ├── SP2010ActivateFeatureForAllSiteCollectionsAndSites.ps1 │ │ ├── SP2010AddAllowedInlineDownloadedMimeTypes.ps1 │ │ ├── SP2010AddCertificateToManageTrust.ps1 │ │ ├── SP2010AddFileTypesToInlineBrowsing.ps1 │ │ ├── SP2010AddListItemsFromCSVFile.ps1 │ │ ├── SP2010AddRemoveSiteCollectionAdmins.ps1 │ │ ├── SP2010AuditLogReport.ps1 │ │ ├── SP2010ChangeManagedAccountPassword.ps1 │ │ ├── SP2010CheckFarmPortsStatus.ps1 │ │ ├── SP2010CheckInDocuments.ps1 │ │ ├── SP2010CompareFilesAndFolders.ps1 │ │ ├── SP2010ConfigureOutgoingEMailSettings.ps1 │ │ ├── SP2010ConfigureRecycleBinSettings.ps1 │ │ ├── SP2010CreateGroups │ │ │ ├── SP2010CreateGroupsFromCSV.ps1 │ │ │ └── SP2010CreateGroupsFromCSVTemplate.csv │ │ ├── SP2010CreateSPListLibrary.ps1 │ │ ├── SP2010CreateServiceAccounts │ │ │ ├── SP2010CreateServiceAccountsFromCSV.ps1 │ │ │ └── SP2010CreateServiceAccountsFromCSVTemplate.csv │ │ ├── SP2010CreateSiteCollectionInExistingContentDB.ps1 │ │ ├── SP2010CreateSiteCollectionInOwnContentDB.ps1 │ │ ├── SP2010CreateUserProfilePictures.ps1 │ │ ├── SP2010CreateUserProfiles │ │ │ ├── CreatePeople.ps1 │ │ │ └── People.csv │ │ ├── SP2010DeleteAllRecycleBinItems.ps1 │ │ ├── SP2010DeleteSPListItems.ps1 │ │ ├── SP2010DeleteSPListItemsPermanently.ps1 │ │ ├── SP2010DeleteUserProfiles.ps1 │ │ ├── SP2010DeleteUsersFromSites.ps1 │ │ ├── SP2010DeploySTSADMExtensionsWithPowerShellCmdlets.ps1 │ │ ├── SP2010DeploySolutionsFromDirectory.ps1 │ │ ├── SP2010DeploySolutionsWithParameters.ps1 │ │ ├── SP2010DownloadBlobsFromDocLibrary.ps1 │ │ ├── SP2010DownloadPreReqs.ps1 │ │ ├── SP2010EnableDeveloperDashboard.ps1 │ │ ├── SP2010EnableObjectCacheOnWebApplications.ps1 │ │ ├── SP2010EnumAllUsersGroups.ps1 │ │ ├── SP2010EnumContentDatabasesAndSiteSizes.ps1 │ │ ├── SP2010EnumFormTemplateLibraries.ps1 │ │ ├── SP2010EnumNavigationLinks.ps1 │ │ ├── SP2010EnumSiteGroups.ps1 │ │ ├── SP2010EnumSitePermissions.ps1 │ │ ├── SP2010EnumSubSitesSizeInASiteCollection.ps1 │ │ ├── SP2010EnumWebUsersGroups.ps1 │ │ ├── SP2010EnumWorkFlows.ps1 │ │ ├── SP2010EnumerateListItems.ps1 │ │ ├── SP2010EnumerateSiteTemplateID.ps1 │ │ ├── SP2010EnumerateWebApplicationPermissions.ps1 │ │ ├── SP2010ExportAllSolutionsFromSolutionStore.ps1 │ │ ├── SP2010ExportSPSite.ps1 │ │ ├── SP2010ExportSingleSolutionsFromSolutionStore.ps1 │ │ ├── SP2010ExportSiteColumns.ps1 │ │ ├── SP2010ExportSiteContentTypes.ps1 │ │ ├── SP2010ExtractDocLibraryToDisk.ps1 │ │ ├── SP2010FlushApplicationBLOBCache.ps1 │ │ ├── SP2010FlushBLOBCache.ps1 │ │ ├── SP2010FlushFarmBLOBCache.ps1 │ │ ├── SP2010GetAllFeaturesOnFilePath.ps1 │ │ ├── SP2010GetAllGroupsAndUsers.ps1 │ │ ├── SP2010GetAllInactiveFeatures.ps1 │ │ ├── SP2010GetAllListColumns.ps1 │ │ ├── SP2010GetAllSiteTemplatesInFarm.ps1 │ │ ├── SP2010GetAllSitesInWebApplication.ps1 │ │ ├── SP2010GetCheckedOutFiles.ps1 │ │ ├── SP2010GetContentTypeQueries.ps1 │ │ ├── SP2010GetCrawlHistoryReport.ps1 │ │ ├── SP2010GetCrawlSchedules.ps1 │ │ ├── SP2010GetDocInventory.ps1 │ │ ├── SP2010GetDuplicateListFields.ps1 │ │ ├── SP2010GetFarmAndSiteCollectionAdmins.ps1 │ │ ├── SP2010GetFarmID.ps1 │ │ ├── SP2010GetLinksReport.ps1 │ │ ├── SP2010GetMissingUserProfileProperties.ps1 │ │ ├── SP2010GetSPFarmInventory.ps1 │ │ ├── SP2010GetSPShellAdmin.ps1 │ │ ├── SP2010GetSharePointW3WP.ps1 │ │ ├── SP2010GetSiteCollectionListGUIDs.ps1 │ │ ├── SP2010GetSiteInventory.ps1 │ │ ├── SP2010GetStartStopSPServices.ps1 │ │ ├── SP2010GetTimerJobHistory.ps1 │ │ ├── SP2010GetUserProfileDetails.ps1 │ │ ├── SP2010GetUserProfiles.ps1 │ │ ├── SP2010GetWebApplicationUsers.ps1 │ │ ├── SP2010GetWorkerProcessPerWebApp.ps1 │ │ ├── SP2010HideListField.ps1 │ │ ├── SP2010HideListFieldLoop.ps1 │ │ ├── SP2010ImportCSVDataIntoList.ps1 │ │ ├── SP2010ImportSPSite.ps1 │ │ ├── SP2010InstallSPInfoPathFormTemplate.ps1 │ │ ├── SP2010LargeListItemsMonitor.ps1 │ │ ├── SP2010ListAllPowerShellCommandlets.ps1 │ │ ├── SP2010MonitorDiagnosticLogs.ps1 │ │ ├── SP2010MonitorWebAppAvailability.ps1 │ │ ├── SP2010MoveSites │ │ │ ├── SP2010MoveSite.ps1 │ │ │ └── SharePoint 2010 Move Site PowerShell Script Usage Guide v1.docx │ │ ├── SP2010PeoplePickerSearchADForests.ps1 │ │ ├── SP2010PublishContentTypeInContentTypeHub.ps1 │ │ ├── SP2010RecycleBinQueries.ps1 │ │ ├── SP2010RecycleBinReport.ps1 │ │ ├── SP2010RemoveListField.ps1 │ │ ├── SP2010RemoveListFieldAll.ps1 │ │ ├── SP2010ResetFarmConfigCache.ps1 │ │ ├── SP2010ResetSearchIndex.ps1 │ │ ├── SP2010RetriveSharePointListData │ │ │ ├── Documentation.htm │ │ │ ├── Documentation_files │ │ │ │ ├── colorschememapping.xml │ │ │ │ ├── filelist.xml │ │ │ │ ├── image001.png │ │ │ │ ├── image002.jpg │ │ │ │ ├── image003.png │ │ │ │ ├── image004.jpg │ │ │ │ ├── image005.png │ │ │ │ ├── image006.jpg │ │ │ │ ├── image007.png │ │ │ │ ├── image008.jpg │ │ │ │ ├── image009.png │ │ │ │ ├── image010.png │ │ │ │ ├── image011.jpg │ │ │ │ ├── item0001.xml │ │ │ │ ├── props002.xml │ │ │ │ └── themedata.thmx │ │ │ ├── RetrieveSharePointListData.ps1 │ │ │ ├── SP2010RetrieveSharePointListData.txt │ │ │ └── en-US │ │ │ │ └── RetriveSharePointListData.psd1 │ │ ├── SP2010RunContentTypeHubTimerJobs.ps1 │ │ ├── SP2010SPFarmWarmup.ps1 │ │ ├── SP2010SearchULSTraceLogs.ps1 │ │ ├── SP2010SetBinPathToEnvironmentVariables.ps1 │ │ ├── SP2010SetLoggingDirectories.ps1 │ │ ├── SP2010SetLoggingLocationPaths.ps1 │ │ ├── SP2010SetSiteCollectionAccessLevels.ps1 │ │ ├── SP2010SetSiteCollectionQuotaTemplates.ps1 │ │ ├── SP2010SetSiteTheme.ps1 │ │ ├── SP2010SetWebApplicationAccessLevels.ps1 │ │ ├── SP2010ShowListFields.ps1 │ │ ├── SP2010SitesAvailabilityMonitor.ps1 │ │ ├── SP2010SolutionDeployer │ │ │ ├── Feature.ps1 │ │ │ ├── SP2010SolutionDeployer.txt │ │ │ ├── Solution.ps1 │ │ │ └── usage.txt │ │ ├── SP2010SyncADUserPropertiesAtSiteCollectionLevel.ps1 │ │ ├── SP2010SynchListUserFields.ps1 │ │ ├── SP2010TestEmailFunctionality.ps1 │ │ ├── SP2010TestNetworkLatency.ps1 │ │ ├── SP2010UpdateListField.ps1 │ │ ├── SP2010UpdateRequestAccessEmail.ps1 │ │ ├── SP2010UpdateUserDisplayNameFromADSync.ps1 │ │ ├── SP2010UpdateUserDisplayNames.ps1 │ │ ├── SP2010UpdateUserProfilePhotoStore.ps1 │ │ ├── SP2010UploadFilesFromFolder.ps1 │ │ ├── SP2010VersionSizeReport.ps1 │ │ ├── SP2010WarmUpEntireFarm.ps1 │ │ ├── SP2010WarmUpFarmURLs.ps1 │ │ ├── SP2010WarmUpSpecificURLs.ps1 │ │ ├── SP2010_Farm_Backup_With_Notification.ps1 │ │ └── SP2010_Site_Collection_Backup_With_Notification.ps1 │ └── SharePoint2013 │ │ ├── DeploySPUserSolutionToSiteCollections.ps1 │ │ ├── SP2013ActivateFeatureForAllSiteCollectionsAndSites.ps1 │ │ ├── SP2013AddAllowedInlineDownloadedMimeTypes.ps1 │ │ ├── SP2013AddAlternateSiteCollectionURLMapping.ps1 │ │ ├── SP2013AddCertificateToManageTrust.ps1 │ │ ├── SP2013AddCrawlRules.ps1 │ │ ├── SP2013AddListItemsFromCSVFile.ps1 │ │ ├── SP2013AddRemoveSiteCollectionAdmins.ps1 │ │ ├── SP2013AddSPShellAdmin.ps1 │ │ ├── SP2013AuditLogReport.ps1 │ │ ├── SP2013ConfigureOutgoingEMailSettings.ps1 │ │ ├── SP2013ConfigureRecycleBinSettings.ps1 │ │ ├── SP2013CreateIsolatedAppDomain.ps1 │ │ ├── SP2013CreateMySitesHNSCWebApplication.ps1 │ │ ├── SP2013CreateSPListLibrary.ps1 │ │ ├── SP2013CreateSiteCollectionInOwnContentDB.ps1 │ │ ├── SP2013DeleteAllRecycleBinItems.ps1 │ │ ├── SP2013DeleteSPListItems.ps1 │ │ ├── SP2013DeleteSPListItemsPermanently.ps1 │ │ ├── SP2013DeleteUserProfiles.ps1 │ │ ├── SP2013DownloadPreReqs.ps1 │ │ ├── SP2013EnableEMailNotificationOnLists.ps1 │ │ ├── SP2013EnumAllUsersGroups.ps1 │ │ ├── SP2013EnumContentDatabasesAndSiteSizes.ps1 │ │ ├── SP2013EnumFormTemplateLibraries.ps1 │ │ ├── SP2013EnumNavigationLinks.ps1 │ │ ├── SP2013EnumSiteCollectionSizes.ps1 │ │ ├── SP2013EnumSiteCollections.ps1 │ │ ├── SP2013EnumSitesAndSubSitesHTMLReport.ps1 │ │ ├── SP2013EnumSubSitesSizeInASiteCollection.ps1 │ │ ├── SP2013EnumWebUsersGroups.ps1 │ │ ├── SP2013EnumWorkFlows.ps1 │ │ ├── SP2013ExportAllSolutionsFromSolutionStore.ps1 │ │ ├── SP2013ExportImportSearchServiceManagedProperties.ps1 │ │ ├── SP2013ExportSPSite.ps1 │ │ ├── SP2013ExportSiteColumns.ps1 │ │ ├── SP2013ExportSiteContentTypes.ps1 │ │ ├── SP2013ExtractDocLibraryToDisk.ps1 │ │ ├── SP2013ExtractSiteWebDocLibrariesToDisk.ps1 │ │ ├── SP2013FlushBLOBCache.ps1 │ │ ├── SP2013GetAllFeaturesOnFilePath.ps1 │ │ ├── SP2013GetAllGroupsAndUsers.ps1 │ │ ├── SP2013GetAllInactiveFeatures.ps1 │ │ ├── SP2013GetAllListColumns.ps1 │ │ ├── SP2013GetAllSiteTemplatesInFarm.ps1 │ │ ├── SP2013GetAllSitesInWebApplication.ps1 │ │ ├── SP2013GetCrawlHistoryReport.ps1 │ │ ├── SP2013GetDuplicateListFields.ps1 │ │ ├── SP2013GetEnterpriseSearchServiceStatus.ps1 │ │ ├── SP2013GetFarmAndSiteCollectionAdmins.ps1 │ │ ├── SP2013GetFarmConfigurationAndEventsReport.ps1 │ │ ├── SP2013GetLinksReport.ps1 │ │ ├── SP2013GetMissingUserProfileProperties.ps1 │ │ ├── SP2013GetSPCorrelationIDLogs.ps1 │ │ ├── SP2013GetSPFarmInventory.ps1 │ │ ├── SP2013GetSPSearchServiceTopologyState.ps1 │ │ ├── SP2013GetSPShellAdmin.ps1 │ │ ├── SP2013GetSharePointW3WP.ps1 │ │ ├── SP2013GetSiteCollectionListGUIDs.ps1 │ │ ├── SP2013GetStartStopSPServices.ps1 │ │ ├── SP2013GetUserProfileDetails.ps1 │ │ ├── SP2013GetUserProfiles.ps1 │ │ ├── SP2013GetWebAnalyticsReport.ps1 │ │ ├── SP2013ImportSPSite.ps1 │ │ ├── SP2013InstallSPInfoPathFormTemplate.ps1 │ │ ├── SP2013LargeListItemsMonitor.ps1 │ │ ├── SP2013ListAllInstalledProducts.ps1 │ │ ├── SP2013ListAllPowerShellCommandlets.ps1 │ │ ├── SP2013MonitorDiagnosticLogs.ps1 │ │ ├── SP2013MonitorWebAppAvailability.ps1 │ │ ├── SP2013MoveSPEnterpriseSearchIndex.ps1 │ │ ├── SP2013PeoplePickerSearchADForests.ps1 │ │ ├── SP2013PublishContentTypeInContentTypeHub.ps1 │ │ ├── SP2013RegisterCertForHighTrustApps.ps1 │ │ ├── SP2013ResetFarmConfigCache.ps1 │ │ ├── SP2013ResetSearchIndex.ps1 │ │ ├── SP2013ResolveEditVsContributePermissions.ps1 │ │ ├── SP2013RunContentTypeHubTimerJobs.ps1 │ │ ├── SP2013SPFarmWarmup.ps1 │ │ ├── SP2013SearchULSTraceLogs.ps1 │ │ ├── SP2013SetContentTypeHubURL.ps1 │ │ ├── SP2013SetDistributedCacheServiceMemory.ps1 │ │ ├── SP2013SetLoggingLocationPaths.ps1 │ │ ├── SP2013SetMaintenanceWindowForWebApplication.ps1 │ │ ├── SP2013SetManagedPropertiesRefinableSortable.ps1 │ │ ├── SP2013SetMaximumFileSizePerExtension.ps1 │ │ ├── SP2013SitesAvailabilityMonitor.ps1 │ │ ├── SP2013SyncADUserPropertiesAtSiteCollectionLevel.ps1 │ │ ├── SP2013TestEmailFunctionality.ps1 │ │ ├── SP2013TestNetworkLatency.ps1 │ │ ├── SP2013UpdateRequestAccessEmail.ps1 │ │ ├── SP2013UpdateSecurityTokenServiceConfig.ps1 │ │ ├── SP2013UpdateUserDisplayNameFromADSync.ps1 │ │ ├── SP2013UpdateUserProfilePhotoStore.ps1 │ │ ├── SP2013UploadFilesFromFolder.ps1 │ │ └── SP2013VersionSizeReport.ps1 │ ├── Snippets │ ├── ClipboardHistoryViewer.ps1 │ ├── ForEachFromCSVImport.ps1 │ ├── GetDotNetFrameworkVersions.ps1 │ ├── GetInternetExplorerTrustedSites.ps1 │ ├── ISEVimEditorTheme.ps1 │ ├── ReadHostArray.ps1 │ └── SearchForPhraseInFiles.ps1 │ ├── TaskScheduler │ ├── EnumScheduledTasks.ps1 │ └── GetScheduledTask.ps1 │ ├── TerminalService │ └── GetActiveTerminalServiceRDPSessions.ps1 │ ├── VMware │ └── DeployESXiPatch.ps1 │ ├── certificates │ ├── BackupCertificateAuthority.ps1 │ ├── Disable-CRLCheckv2.ps1 │ ├── GenerateCertificateSigningRequest(CSR).ps1 │ ├── GetCertificatesInFilePath.ps1 │ ├── GetInstalledCertificates.ps1 │ └── UpgradeCertificateAuthority.ps1 │ ├── diskspace │ ├── DiskSpaceHTMLEmailReport.ps1 │ ├── DiskSpaceHTMLReport.ps1 │ ├── DiskSpacePercentageUsedGraph.ps1 │ ├── GetClusterSharedVolumesCSVSpace.ps1 │ └── diskspacereport │ │ ├── diskspace.ps1 │ │ ├── list.txt │ │ └── start.bat │ ├── email │ ├── SMTPEmailTest.ps1 │ ├── SendEmailWithAttachment.ps1 │ ├── SendEmailWithHTML.ps1 │ └── SendEmailWithMultipleAttachments.ps1 │ ├── eventlogs │ └── monitor_windows_event_logs.ps1 │ ├── files │ ├── CheckForFilesWithEmailAlert.ps1 │ ├── DeleteFilesAfterNumberOfDays.ps1 │ ├── DeleteFilesAfterNumberOfDaysFunction.ps1 │ ├── DirectoryFilesMonitor.ps1 │ ├── FindFilesInDirectory.ps1 │ ├── ListFileSizesInDirectoryFunction.ps1 │ ├── ListMoveDeleteFilesAfterNumberOfDays.ps1 │ ├── ListOrDeleteFilesAfterNumberOfDays.ps1 │ ├── MoveBackupFiles.ps1 │ ├── ReplaceStringInFilesInDirectory.ps1 │ ├── SortAndMoveFilesToDateFolders.ps1 │ └── search_string_match_in_files.ps1 │ ├── hotfixes │ ├── CompareHotFixes.ps1 │ └── Get-HotFixReport.ps1 │ ├── iis │ ├── IIS_Change_Log_File_Location.ps1 │ ├── IIS_Create_Shortcuts_To_Log_Files.ps1 │ ├── IIS_Get_All_App_Pool_Credentials.ps1 │ ├── IIS_Get_App_Pool_Credentials.ps1 │ ├── IIS_Get_Web_Apps_And_Identity_Details.ps1 │ ├── IIS_Get_Web_Sites.ps1 │ └── IIS_Recycle_App_Pool_Remotely.ps1 │ ├── network │ ├── MonitorPorts.pdf │ ├── MonitorPorts.ps1 │ └── MonitorTCPAndUDPConnections.ps1 │ ├── o365 │ ├── AssignMSOnlineRoleDelegationToUsers.ps1 │ ├── AssignMSOnlineUserPlanLicenses.ps1 │ ├── ConnectToExchangeOnline.ps1 │ ├── ConnectToMSOnline.ps1 │ ├── ConnectToMSOnlineAndExchangeOnlineFunction.ps1 │ ├── ConnectToMultipleMSOnlineServices.ps1 │ ├── DirSyncStartOnlineCoexistenceSync.ps1 │ ├── ExchangeOnline │ │ ├── ExchangeOnlineCheckDistributionGroupSync.ps1 │ │ ├── ExchangeOnlineDisableOffice365GroupCreation.ps1 │ │ ├── ExchangeOnlineGetDistributionGroupMemberReports.ps1 │ │ ├── ExchangeOnlineGetDistributionGroupMembers.ps1 │ │ ├── ExchangeOnlineGetMailBoxPermissions.ps1 │ │ ├── ExchangeOnlineGetMailBoxStatistics.ps1 │ │ ├── ExchangeOnlineGetMailboxLocations.ps1 │ │ ├── ExchangeOnlineGetOffice365GroupsReports.ps1 │ │ ├── ExchangeOnlineGetUserDetails.ps1 │ │ ├── ExchangeOnlineProtectionGetMailTrafficReports.ps1 │ │ ├── ExchangeOnlineSetMailBoxAuditing.ps1 │ │ └── ExchangeOnlineSetUserPhoto.ps1 │ ├── GetExchangeOnlineDistributionListMembers.ps1 │ ├── GetMSOnlineAdminUsers.ps1 │ ├── GetMSOnlineGroupsLastDirSyncTime.ps1 │ ├── GetMSOnlineGroupsWithoutLastDirSyncTime.ps1 │ ├── GetMSOnlineHealthStatusReport.ps1 │ ├── GetMSOnlineServiceHealthIncidentsEmail.ps1 │ ├── GetMSOnlineTenantID.ps1 │ ├── GetMSOnlineUserLicensePlansAssignment.ps1 │ ├── GetMSOnlineUserLicenses.ps1 │ ├── GetMSOnlineUserLicensesUsage.ps1 │ ├── GetMSOnlineUserReport.ps1 │ ├── MSOnlineGetAllPowerShellModules.ps1 │ ├── O365-Fed-MetaData-Update-Task-Installation.ps1 │ ├── OneDrive │ │ └── MSOnlineAddOneDriveBlockedFileExtensions.ps1 │ ├── SharePointOnline │ │ ├── SPOnlineActivateSiteCollectionFeature.ps1 │ │ ├── SPOnlineAddDocumentsToLibrary.ps1 │ │ ├── SPOnlineAddSiteCollectionAdministrators.ps1 │ │ ├── SPOnlineAddUsersAndGroupsFromCSVFile.ps1 │ │ ├── SPOnlineCreatePersonalSiteCollectionsFromCSVFile.ps1 │ │ ├── SPOnlineCreateSiteCollectionsFromCSVFile.ps1 │ │ ├── SPOnlineDeleteSiteCollection.ps1 │ │ ├── SPOnlineDownloadFileFunction.ps1 │ │ ├── SPOnlineEnableDisableCustomScriptForSiteCollections.ps1 │ │ ├── SPOnlineEnableSideLoadingForSiteCollections.ps1 │ │ ├── SPOnlineGetAllOneDriveSiteDetails.ps1 │ │ ├── SPOnlineGetAllSiteCollectionDetails.ps1 │ │ ├── SPOnlineGetAllUserProfileServiceUserProfiles.ps1 │ │ ├── SPOnlineGetContentTypes.ps1 │ │ ├── SPOnlineGetPersonalSiteCollections.ps1 │ │ ├── SPOnlineReindexSiteCollectionsAndSites.ps1 │ │ ├── SPOnlineRemoveDeletedSiteCollection.ps1 │ │ ├── SPOnlineRenewAddInsClientSecrets.ps1 │ │ ├── SPOnlineSiteCollectionCommandsFromCSVInput.ps1 │ │ └── SPOnlineUpdateListItemsFromCSV.ps1 │ └── Yammer │ │ └── YammerUserMatchToAzureAD.ps1 │ ├── quest │ └── EnumOperatingSystems.ps1 │ ├── security │ ├── EncryptCredentialsForPSRemoting.ps1 │ ├── EncryptedCredentialsFunctions.ps1 │ └── GenerateSecurePasswords.ps1 │ ├── services │ └── RestartWindowsServices.ps1 │ ├── systeminfo │ ├── GetNicConfiurationDetails.ps1 │ ├── SystemInfoInventory.ps1 │ ├── SystemInfoOnServers.ps1 │ ├── SystemInfoReportEmail.ps1 │ └── SystemInfoReportHTML.ps1 │ ├── telnet │ └── PowerShellTelnetRemoteSession.ps1 │ └── web │ ├── WebPageLoadTimesTest.ps1 │ ├── WebRequestTest.ps1 │ ├── WebSiteAvailabilityMonitor.ps1 │ └── WebSiteAvailabilityMonitorWithServiceRestart.ps1 ├── SQLServer └── Working │ ├── AzureSQLEnumDatabaseUsersAndRoles.sql │ ├── SQLAttachDatabase.sql │ ├── SQLBackupDatabasesToDiskWithCopyOnly.sql │ ├── SQLBackupHistoryAnalysis.sql │ ├── SQLBackupHistoryQueries.sql │ ├── SQLDropDatabases.sql │ ├── SQLEnumClientConnectionDetails.sql │ ├── SQLEnumClientConnections.sql │ ├── SQLEnumCurrentExecutingTransactions.sql │ ├── SQLEnumDatabaseSizeAndFileGrowth.sql │ ├── SQLEnumDatabaseSizes.sql │ ├── SQLEnumDatabaseStoredProcs.sql │ ├── SQLEnumDatabaseTableSizes.sql │ ├── SQLEnumDatabaseUsersAndRoles.sql │ ├── SQLEnumDatabasesAndLogFileSizes.sql │ ├── SQLEnumFileGrowth.sql │ ├── SQLEnumPortsAndProtocols.sql │ ├── SQLEnumTableSizes.sql │ ├── SQLFindTextInDatabaseTablesAndColumns.sql │ ├── SQLGenerateAttachAndDetachCommands.sql │ ├── SQLGetHostClusterNodesDatabaseLocationsVolumesSizes.sql │ ├── SQLGetInstanceConfigurationDetails.sql │ ├── SQLGetInstanceDetailsSummary.sql │ ├── SQLOutputDatabaseUsersAndRolesGenerationScript.sql │ ├── SQLOutputInstanceUsersAndRolesGenerationScript.sql │ ├── SQLRebuildIndexesForAllDatabases.sql │ ├── SQLRecentFullDifferentialLogBackupHistory.sql │ ├── SQLRestoreHistoryAnalysis.sql │ ├── SQLSCCMGetAllRegisteredMachines.sql │ ├── SQLSetAllDatabasesRecoveryModels.sql │ ├── SQLSharePointAllDocsQueries.sql │ ├── SQLSharePointDatabaseNamesAgainstGUIDs.sql │ ├── SQLSharePointDatabaseStatisticsStatusChecks.sql │ ├── SQLSharePointDocsVersionsReport.sql │ ├── SQLSharePointFilePathLengthQueries.sql │ ├── SQLSharePointListDocAndFormLibraries.sql │ ├── SQLSharePointListMySites.sql │ ├── SQLSharePointListTemplateNamesAndIDs.sql │ ├── SQLSharePointSiteSizeQueries.sql │ ├── SQLSharePointTruncateUsageAndHealthDatabase.sql │ ├── SQLShrinkTransactionLogs.sql │ └── SQLTopIOQueries.sql └── ServiceNow ├── ServiceNowMergeDuplicateUserRecords.js └── ServiceNowRecordProducerPopulateIncidentRecord.js /BATCH/WIP/sharepoint/moss2007/AutomatedSharePoint2007FarmConfigurationBatchFile/Resource.txt: -------------------------------------------------------------------------------- 1 | URL: http://blog.henryong.com/2010/04/23/automated-sharepoint-2007-farm-configuration-batch-file -------------------------------------------------------------------------------- /BATCH/WIP/sharepoint/moss2007/GaryLapointeSharePoint2007Install/InstallScript/Lapointe.SharePoint.STSADM.Commands.wsp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/BATCH/WIP/sharepoint/moss2007/GaryLapointeSharePoint2007Install/InstallScript/Lapointe.SharePoint.STSADM.Commands.wsp -------------------------------------------------------------------------------- /BATCH/WIP/sharepoint/moss2007/GaryLapointeSharePoint2007Install/Resource.txt: -------------------------------------------------------------------------------- 1 | URL: http://blog.falchionconsulting.com/index.php/2008/03/sample-install-script -------------------------------------------------------------------------------- /BATCH/Working/IIS/GetAppPoolPassword.bat: -------------------------------------------------------------------------------- 1 | :: Batch file script to retrieve IIS Server App Pool Properties :: 2 | :: Useful for retrieving the App Pool Password :: 3 | :: Usage: Run as an administrator and supply the appropriate App Pool Name when prompted :: 4 | @ECHO OFF 5 | :Start 6 | SET /P AppPoolName=Please Enter Your App Pool Name: 7 | IF "%AppPoolName%"=="" GOTO Error 8 | %systemroot%\system32\inetsrv\APPCMD list apppool "%AppPoolName%" /text:* 9 | :Error 10 | ECHO "That App Pool Name doesn't appear to exist, please try again" 11 | GOTO Start 12 | -------------------------------------------------------------------------------- /BATCH/Working/SharePoint/InstallNewInfoPathFormTemplate.bat: -------------------------------------------------------------------------------- 1 | ::BATCH script to upload / install a new infopath form template, and activate it for a particular site collection (uses STSADM commands) 2 | ::Publish the form to a location lets say it is published at C:\InfoPathForms\Publish\sample.xsn 3 | cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN 4 | ::uncomment the below three lines if you want to uninstall and re-install the infopath form template 5 | ::stsadm.exe -o DeActivateFormTemplate -url http://demosite -filename ::C:\InfoPathForms\Publish\sample.xsn 6 | ::stsadm.exe -o RemoveFormTemplate C:\InfoPathForms\Publish\sample.xsn 7 | ::stsadm.exe -o execadmsvcjobs 8 | stsadm.exe -o verifyformtemplate -filename C:\InfoPathForms\Publish\sample.xsn 9 | stsadm.exe -o UploadFormTemplate -filename C:\InfoPathForms\Publish\sample.xsn 10 | stsadm.exe -o execadmsvcjobs 11 | stsadm.exe -o ActivateFormTemplate -url http://demosite -filename C:\InfoPathForms\Publish\sample.xsn -------------------------------------------------------------------------------- /BATCH/Working/SharePoint/UpgradeInfoPathFormTemplate.bat: -------------------------------------------------------------------------------- 1 | ::BATCH script to update / upgrade an infopath form template, and activate it for a particular site collection (uses STSADM commands) 2 | cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN 3 | stsadm.exe -o DeActivateFormTemplate -url http://demosite -filename C:\InfoPathForms\Publish\sample.xsn 4 | stsadm.exe -o verifyformtemplate -filename C:\InfoPathForms\Publish\sample.xsn 5 | stsadm.exe -o UpgradeFormTemplate -filename C:\InfoPathForms\Publish\sample.xsn 6 | stsadm.exe -o execadmsvcjobs 7 | stsadm.exe -o ActivateFormTemplate -url http://demosite -filename C:\InfoPathForms\Publish\sample.xsn -------------------------------------------------------------------------------- /BATCH/Working/System/EmptyRecycleBin.bat: -------------------------------------------------------------------------------- 1 | :: Batch file script to Empty the Recycle Bin for Every User on a System :: 2 | :: Tested on Windows 2008/R2 and 2012/R2 Editions :: 3 | rd /s c:\$Recycle.Bin -------------------------------------------------------------------------------- /PowerShell/Working/AD/GetADGroupManagedBy.ps1: -------------------------------------------------------------------------------- 1 | ## Active Directory: PowerShell Script to Get AD Groups Details Including the Manager (ManagedBy) Property ## 2 | 3 | ### Start Variables ### 4 | $GroupName = "Sharepoint" #Provide your Group Name filter, or leave blank to report on all Groups in the domain 5 | $ReportPath = "C:\ztemp\Scripts\GetADGroupsReport.csv" #Change this path to match your environment 6 | ### End Variables ### 7 | 8 | Import-Module ActiveDirectory 9 | 10 | Get-ADGroup -filter * -property Managedby | Where {$_.name -like "*$GroupName*"}| select Name, @{N='Managedby';E={$_.Managedby.Substring($_.Managedby.IndexOf("=") + 1, $_.Managedby.IndexOf(",") - $_.Managedby.IndexOf("=") - 1)}} | Export-CSV "$ReportPath" -NoTypeInformation -Encoding "Default" -------------------------------------------------------------------------------- /PowerShell/Working/AD/GetADUserPasswordLastSetReport.ps1: -------------------------------------------------------------------------------- 1 | ## Active Directory: PowerShell Script to Check when Users Passwords Were Last Set (Changed) With CSV Output ## 2 | 3 | ## Usage: Provide a numeric value to the 'AddDays' property, and provide a path to the 'Export-CSV' command to match your requirements before running the script 4 | 5 | Import-Module activedirectory 6 | $When = ((Get-Date).AddDays(-30)).Date #Change the 'AddDays' property to match the number of Days back you want to query 7 | Get-ADUser -filter {whenCreated -ge $When} -properties * | sort-object UserPrincipalName | select-object UserPrincipalName, Name, passwordlastset, passwordneverexpires | Export-CSV -path "c:\BoxBuild\RecentUserPassWordChanges.csv" -NoTypeInformation #Change this path to match your environment -------------------------------------------------------------------------------- /PowerShell/Working/AD/GetADUserPropertiesToCSV.ps1: -------------------------------------------------------------------------------- 1 | ## Active Directory: PowerShell Script That Uses The Get-ADUser Commandlet To Retrieve User Properties Against An OU With Output To A CSV File ## 2 | 3 | ## Resource for Get-ADUser Properties: http://social.technet.microsoft.com/wiki/contents/articles/12037.active-directory-get-aduser-default-and-extended-properties.aspx 4 | 5 | ## Usage: Change your '-Prop', '-Server', '-SearchBase' parameters to match your requirements and change the path under 'Export-CSV' to match your environment 6 | 7 | ## Tip: By default the Export-CSV Cmdlet exports the CSV file in ASCII format. To change this to Unicode or UTF8 format use the Encoding parameter: -Encoding "Unicode" 8 | 9 | Import-Module ActiveDirectory -ErrorAction SilentlyContinue 10 | 11 | Get-ADUser -Filter * -Prop GivenName,Surname,SamAccountName,EmailAddress,Description,whenCreated,DistinguishedName -Server "ServerName.ext.YourDomain.com" -SearchBase "OU=External Users,DC=ext,DC=YourDomain,DC=com" | 12 | Export-CSV "C:\BoxBuild\Scripts\ADUsersReport.csv" -NoTypeInformation #Change this path to match your environment with a local drive or network location -------------------------------------------------------------------------------- /PowerShell/Working/AD/GetADUserThumbnailPhotos.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script to Export User Account Thumbnail Photos (thumbnailPhoto) From Active Directory (AD) to Disk ## 2 | 3 | ## Overview: PowerShell Script that uses the 'ActiveDirectory' Module to get all AD users thumbnail photos, and exports these to a file location in JPG file format 4 | 5 | ## Usage: Edit the '$Directory' variable to match your environment and run the script. Feel free to add additional parameters to the 'GET-ADuser' commandlet 6 | 7 | Import-Module "ActiveDirectory" -ErrorAction SilentlyContinue 8 | 9 | $list=GET-ADuser –filter * -properties thumbnailphoto 10 | 11 | Foreach ($User in $list) 12 | 13 | { 14 | 15 | $Directory='C:\ztemp\ADPhotos\' #Change this path to match your environment (Note: Remember to keep the trailing '\' backslash) 16 | 17 | If ($User.thumbnailphoto) 18 | 19 | { 20 | 21 | $Filename=$Directory+$User.samaccountname+'.jpg' 22 | 23 | [System.Io.File]::WriteAllBytes($Filename, $User.Thumbnailphoto) 24 | 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /PowerShell/Working/AD/GetRecentADUserAccounts.ps1: -------------------------------------------------------------------------------- 1 | ## Active Directory: PowerShell Script to Get Recently Created Users With CSV Output ## 2 | 3 | ## Usage: Provide a numeric value to the 'AddDays' property, and provide a path to the 'Export-CSV' command to match your requirements before running the script 4 | 5 | Import-Module activedirectory 6 | $When = ((Get-Date).AddDays(-1)).Date #Change the 'AddDays' property to match the number of Days back you want to query 7 | Get-ADUser -Filter {whenCreated -ge $When} -Properties * | Select UserPrincipalName, DisplayName, GivenName, Surname, Title, EmailAddress, Department, OfficePhone, MobilePhone, Office, Company, Enabled, EmployeeNumber, @{N='Manager';E={$_.Manager.Substring($_.Manager.IndexOf("=") + 1, $_.Manager.IndexOf(",") - $_.Manager.IndexOf("=") - 1)}}, WhenCreated | Export-CSV "C:\BoxBuild\Scripts\RecentlyCreatedUsers.csv" -NoTypeInformation -Encoding "Default" 8 | -------------------------------------------------------------------------------- /PowerShell/Working/AD/GetThumbnailPhotoSize.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/AD/GetThumbnailPhotoSize.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/AD/GetUserPasswordLastSetDetails.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script to Query Active Directory to Get Password Last Set and Password Expiration Details ## 2 | 3 | ## Usage Example: Get-UserDetails 'cdee' 4 | 5 | Import-Module ActiveDirectory 6 | 7 | function Get-UserDetails([string]$user) { 8 | Get-ADUser $user -Properties PasswordLastSet, PasswordNeverExpires #Tip: Use a '*' after properties to get all available attributes related to a user 9 | } 10 | -------------------------------------------------------------------------------- /PowerShell/Working/AD/GetUsersLastLogonDateTime.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script to Query Active Directory to Return All Users Last Logon Date and Time ## 2 | 3 | $SearchAD = New-Object DirectoryServices.DirectorySearcher([adsi]"") 4 | 5 | $SearchAD.filter = "(objectclass=user)" 6 | $users = $SearchAD.findall() 7 | 8 | Foreach($user in $users) 9 | { 10 | if($user.properties.item("lastLogon") -ne 0) 11 | { 12 | $a = [datetime]::FromFileTime([int64]::Parse($user.properties.item("lastLogon"))) 13 | "$($user.properties.item(`"name`")) $a" 14 | } 15 | } -------------------------------------------------------------------------------- /PowerShell/Working/AD/SetADAccountasLocalAdministrator.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/AD/SetADAccountasLocalAdministrator.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/ADFS/ExportAndImportADFSClaimRules.ps1: -------------------------------------------------------------------------------- 1 | ## ADFS: PowerShell Script That Uses The ADFS PowerShell Snapin To Export And Import Relying Party Trust Claim Rules ## 2 | ## Resources: http://kingofidentity.wordpress.com/2011/04/23/backing-up-and-restoring-claims-in-adfs-2-0; http://botsikas.blogspot.ch/2012/11/adfs-export-and-import-claim.html 3 | 4 | Add-PSSnapin "Microsoft.ADFS.PowerShell" -ErrorAction SilentlyContinue 5 | 6 | ##### BEGIN VARIABLES ##### 7 | $SourceRelyingPartyTrust = "ServiceNow Dev Instance" #The name of your Source Relying Party Trust 8 | $TargetRelyingPartyTrust = "ServiceNow Prod Instance" #The name of your Target Relying Party Trust 9 | $XMLFilePath = "C:\BoxBuild\Scripts\PowerShell\RelyingPartyTrustClaimRules.xml" #The file path and name of the Claim Rules XML export 10 | ##### END VARIABLES ##### 11 | 12 | ##Export Relying Party Trust Claims 13 | Get-ADFSRelyingPartyTrust -Name $SourceRelyingPartyTrust | Export-Clixml $XMLFilePath 14 | 15 | ##Import Relying Party Trust Claims 16 | Import-Clixml $XMLFilePath | foreach-object {Set-ADFSRelyingPartyTrust -TargetName $TargetRelyingPartyTrust -IssuanceTransformRules $_.IssuanceTransformRules} -------------------------------------------------------------------------------- /PowerShell/Working/ADFS/SetMSOnlineFederationToADFS.ps1: -------------------------------------------------------------------------------- 1 | ## ADFS: Add MSOnline Federation to ADFS ## 2 | 3 | ## Run the example commands below within the Windows Azure Active Directory PowerShell Module installed on your Primary ADFS server 4 | 5 | ## Versions: ADFS 2.0 / 3.0 6 | 7 | ## Resources: 8 | 9 | #http://blogs.technet.com/b/canitpro/archive/2015/09/11/step-by-step-setting-up-ad-fs-and-enabling-single-sign-on-to-office-365.aspx 10 | 11 | #https://www.helloitsliam.com/2015/01/23/sharepoint-2013-and-adfs-with-multiple-domains/ 12 | 13 | #Add the ADFS PowerShell Module for ADFS 2.0 14 | Add-PSSnapin "microsoft.adfs.powershell" -ErrorAction SilentlyContinue 15 | 16 | #Import the ADFS PowerShell Module for ADFS 3.0+ 17 | Import-Module ADFS 18 | 19 | #Import the Windows Azure MSOnline PowerShell Modules 20 | Import-Module MSOnline 21 | Import-Module MSOnlineExtended 22 | 23 | $cred =Get-Credential 24 | 25 | Connect-MsolService –Credential $cred 26 | 27 | Set-MsolADFSContext –Computer adfs_servername.domain_name.com #internal FQDN of the Primary ADFS server 28 | 29 | Convert-MsolDomainToFederated –DomainName domain_name.com 30 | 31 | Get-MsolFederationProperty –DomainName domain_name.com -------------------------------------------------------------------------------- /PowerShell/Working/Azure/AzureADConnectGetADSyncServerConfiguration.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script to Get the Azure Active Directory Synchronization Client Configuration XML Files (Azure AD Connect / AAD Connect) ## 2 | 3 | ## This script outputs XML configuration files to the location specified in the '$ConfigurationPath' variable into the following directories: Connectors; GlobalSettings; SynchronizationRules 4 | 5 | $ConfigurationPath = "C:\BoxBuild\AzureADConnectSyncDocumenter\Data\MachineName" #Change this path to match your environment 6 | 7 | Import-Module ADSync 8 | 9 | Get-ADSyncServerConfiguration -Path "$ConfigurationPath" 10 | 11 | Get-ChildItem $ConfigurationPath -------------------------------------------------------------------------------- /PowerShell/Working/Azure/AzureADConnectGetConnectorSyncErrors.ps1: -------------------------------------------------------------------------------- 1 | ## Azure AD Connect: PowerShell Script to Export and Analyse the AAD Connect FIM Client Sync Errors ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script that uses AAD Connect Sync tools to Export (CSExport.exe), and Analyse (CSExportAnalyzer.exe) the FIM Client Sync Errors 6 | 7 | Usage: Edit the variables below to match your AAD Connect environment and run the script 8 | 9 | Resources: 10 | 11 | http://www.highclouder.com/azure-ad-connect-export-user-error-data 12 | https://technet.microsoft.com/en-us/library/jj590346(v=ws.10).aspx 13 | 14 | #> 15 | 16 | ### Start Variables ### 17 | $ConnectorName = "YourTenant.onmicrosoft.com - AAD" 18 | $ErrorsFile = "C:\BoxBuild\Errors-Export.xml" 19 | $ReportFile = "C:\BoxBuild\Errors-Export.csv" 20 | ### End Variables ### 21 | 22 | cd "C:\Program Files\Microsoft Azure AD Sync\bin" 23 | 24 | # Export the errors to an XML file 25 | ./CSExport.exe $ConnectorName $ErrorsFile /f:e 26 | 27 | # Process the errors XML to a CSV file for analysis 28 | ./CSExportAnalyzer.exe $ErrorsFile > $ReportFile 29 | -------------------------------------------------------------------------------- /PowerShell/Working/Azure/AzureADConnectGetLocalSQLInstance.ps1: -------------------------------------------------------------------------------- 1 | ## Azure AD Connect: PowerShell Script to Get the Local SQL Instance Connection Details (Named Pipes) ## 2 | 3 | <# 4 | 5 | Example of connection output to put into your SQL Client Connection: \\.\pipe\LOCALDB#SH618D23\tsql\query 6 | 7 | Resource: https://itfordummies.net/2017/02/13/manage-localdb-aad-connect-sql-database 8 | 9 | #> 10 | 11 | $LocalSQLInstancePath = "C:\Program Files\Microsoft SQL Server\110\Tools\Binn" #Change this path if your local SQL instance path differs to the default installation location 12 | 13 | Set-Location -Path $LocalSQLInstancePath 14 | 15 | .\SqlLocalDB.exe info 16 | 17 | .\SqlLocalDB.exe info .\ADSync -------------------------------------------------------------------------------- /PowerShell/Working/Azure/AzureADConnectSetPreventAccidentalDeletes.ps1: -------------------------------------------------------------------------------- 1 | ## Azure AD Connect: PowerShell Commands to Configure Accidental Deletion Functionality (Prevent Accidental Deletes) ## 2 | 3 | ## Resource: http://blog.kloud.com.au/2015/08/05/azure-active-directory-connect-export-profile-error-stopped-server-down 4 | 5 | ## AAD Connect Commandlets: https://mikecrowley.wordpress.com/2015/10/11/azure-ad-connect-powershell-cmdlets 6 | 7 | #Import the Azure AD Connect Sync module 8 | 9 | Import-Module ADSync 10 | 11 | #Disable / Enable ADSync export deletion threshold 12 | 13 | Disable-ADSyncExportDeletionThreshold 14 | 15 | #Enable-ADSyncExportDeletionThreshold 16 | 17 | #Confirm the status of the 'ADSyncExportDeletionThreshold' property 18 | 19 | Get-ADSyncExportDeletionThreshold -------------------------------------------------------------------------------- /PowerShell/Working/Azure/AzureCloudShellCommands.ps1: -------------------------------------------------------------------------------- 1 | ## Azure: PowerShell Commands For Managing Azure Cloud Shell ## 2 | 3 | #Get CloudDrive details including Cloud Shell Directory (MountPoint) 4 | Get-CloudDrive 5 | 6 | #Dismount CloudDrive will dismount the Azure file share from the current storage account 7 | Dismount-CloudDrive 8 | 9 | #HTML Snippet to Embed an Azure Cloud Shell Session in a HTML Page 10 | 11 | -------------------------------------------------------------------------------- /PowerShell/Working/Azure/ConnectToAzurePowerShellModules.ps1: -------------------------------------------------------------------------------- 1 | ## Azure: PowerShell Commands For Importing and Connecting with the Azure PowerShell Modules (Azure and AzureRM) ## 2 | 3 | ## Connecting to Azure Service Management ## 4 | 5 | Import-Module Azure 6 | 7 | Add-AzureAccount 8 | 9 | #Get-AzureSubscription -ExtendedDetails 10 | #Get-AzureVM 11 | #Get-AzureWebsite 12 | 13 | ## Connecting to Azure Resource Management ## 14 | 15 | ## Dependencies: Windows Management Framework 5.0 | http://www.microsoft.com/en-us/download/details.aspx?id=48729 16 | 17 | Import-Module AzureRM 18 | 19 | Login-AzureRmAccount 20 | 21 | #Get-AzureRmSubscription 22 | #Get-AzureRmSubscription –SubscriptionName "Microsoft Azure Enterprise" | Select-AzureRmSubscription 23 | #Get-AzureRmSubscription –SubscriptionId "00000-0000-0000-000-0000" | Select-AzureRmSubscription -------------------------------------------------------------------------------- /PowerShell/Working/Azure/GetAzureRmADApplication.ps1: -------------------------------------------------------------------------------- 1 | ## AzureRM: PowerShell Script to Get Azure AD Application Details with Azure Resource Manager ## 2 | 3 | Import-Module "AzureRM" 4 | 5 | Login-AzureRmAccount 6 | 7 | #Get-AzureRmADApplication 8 | #Get-AzureRmADApplication -DisplayNameStartWith "zz" #Change this to match your application Display Name 9 | Get-AzureRmADApplication | Select DisplayName, ReplyUrls | Format-Table -------------------------------------------------------------------------------- /PowerShell/Working/Azure/GetAzureRmResourceGroupDeployment.ps1: -------------------------------------------------------------------------------- 1 | ## Azure: Useful Azure RM Resource Group Deployment Commands (AzureRMResourceGroupDeployment) ## 2 | 3 | ## Resource: https://docs.microsoft.com/en-us/powershell/module/azurerm.resources/?view=azurermps-5.3.0 4 | 5 | # Get Azure RM Resource Group Deployment Details 6 | Get-AzureRmResourceGroupDeployment -ResourceGroupName "YourResourceGroupName" 7 | Get-AzureRmResourceGroupDeployment -ResourceGroupName "YourResourceGroupName" | Select DeploymentName, ResourceGroupName, ProvisioningState 8 | 9 | # Stop Azure RM Resource Group Deployment 10 | Stop-AzureRmResourceGroupDeployment -ResourceGroupName "YourResourceGroupName" -Name "YourDeploymentName" -------------------------------------------------------------------------------- /PowerShell/Working/Azure/InstallImportAzurePowerShell.ps1: -------------------------------------------------------------------------------- 1 | ## Azure: PowerShell Commands For Installing and Importing The Azure PowerShell Modules ## 2 | 3 | <# 4 | 5 | Version: Azure PowerShell 1.0 (Preview) 6 | 7 | Dependencies: Windows Management Framework 5.0 | http://www.microsoft.com/en-us/download/details.aspx?id=48729 8 | 9 | Resources: 10 | 11 | https://github.com/Azure/azure-powershell 12 | 13 | https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/#Install 14 | 15 | https://azure.microsoft.com/en-us/blog/azps-1-0-pre 16 | 17 | http://www.microsoft.com/en-us/download/details.aspx?id=48729 (Windows Management Framework 5.0) 18 | 19 | #> 20 | 21 | ## Installing and Importing the Azure PowerShell Modules ## 22 | 23 | # Install all of the AzureRM.* modules 24 | Install-Module AzureRM 25 | 26 | Install-AzureRM 27 | 28 | Install-Module Azure 29 | 30 | # Import all of the AzureRM.* modules within the known semantic version range 31 | Import-AzureRM 32 | 33 | # Import Azure Service Management 34 | Import-Module Azure -------------------------------------------------------------------------------- /PowerShell/Working/DNS/GetDNSRecordsForAllZones.ps1: -------------------------------------------------------------------------------- 1 | ## DNS: PowerShell Script to List All DNS Records in Each Zone on a Windows DNS Server ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script to list all DNS records in each zone on a Windows DNS server (includes sub-zones) 6 | 7 | Note: Script works on DNS role servers, along with AD / DNS role servers 8 | 9 | Usage: Provide your DNS server under the '$DNSServer' variable and edit the '$Results' output properties to match your environment 10 | 11 | Resource: http://sigkillit.com/2015/10/27/list-all-dns-records-with-powershell 12 | 13 | #> 14 | 15 | $DNSServer = "YourServerName" #Provide your DNS Server Name or IP address here 16 | $Zones = @(Get-DnsServerZone -ComputerName $DNSServer) 17 | ForEach ($Zone in $Zones) { 18 | Write-Host "`n$($Zone.ZoneName)" -ForegroundColor "Green" 19 | $Results = $Zone | Get-DnsServerResourceRecord -ComputerName $DNSServer 20 | echo $Results > "C:\BoxBuild\DNS\$($Zone.ZoneName).txt" 21 | #echo $Results | Export-Csv "C:\BoxBuild\DNS\$($Zone.ZoneName).csv" -NoTypeInformation 22 | } -------------------------------------------------------------------------------- /PowerShell/Working/DNS/UpdateDNSARecordIPAddress.ps1: -------------------------------------------------------------------------------- 1 | ## DNS: PowerShell Script to Update an IP Address for an 'A' Record on a Windows DNS Server ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script to Update an IP Address for an 'A' Record on a Windows DNS Server 6 | 7 | Note: Script works on DNS role servers, along with AD / DNS role servers 8 | 9 | Usage: Provide your variables to match your requirements and run the script 10 | 11 | #> 12 | 13 | ### Start Variables ### 14 | $DNSName = "YourDNSName" 15 | $DNSZoneName = "YourDomain.com" 16 | $IPAddress = "10.0.0.1" 17 | ### End Variables ### 18 | 19 | $oldobj = get-dnsserverresourcerecord -name $DNSName -zonename $DNSZoneName -rrtype "A" 20 | $newobj = get-dnsserverresourcerecord -name $DNSName -zonename $DNSZoneName -rrtype "A" 21 | $newobj.recorddata.ipv4address=[System.Net.IPAddress]::parse($IPAddress) 22 | Set-dnsserverresourcerecord -newinputobject $newobj -oldinputobject $oldobj -zonename $DNSZoneName -passthru -------------------------------------------------------------------------------- /PowerShell/Working/DateTime/GetDateFormatOptions.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Useful Script to display Get-Date Format Info Options ## 2 | 3 | ## Resources: http://jdhitsolutions.com/blog/2014/10/powershell-dates-times-and-formats; http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo%28VS.85%29.aspx 4 | 5 | $patterns = "d","D","g","G","f","F","m","o","r","s", "t","T","u","U","Y","dd","MM","yyyy","yy","hh","mm","ss","yyyyMMdd","yyyyMMddhhmm","yyyyMMddhhmmss" 6 | 7 | Write-host "It is now $(Get-Date)" -ForegroundColor Green 8 | 9 | foreach ($pattern in $patterns) { 10 | 11 | #create an Object 12 | [pscustomobject]@{ 13 | Pattern = $pattern 14 | Syntax = "Get-Date -format '$pattern'" 15 | Value = (Get-Date -Format $pattern) 16 | } 17 | 18 | } #foreach 19 | 20 | Write-Host "Most patterns are case sensitive" -ForegroundColor Green -------------------------------------------------------------------------------- /PowerShell/Working/DirSync/DirSyncSetPreventAccidentalDeletes.ps1: -------------------------------------------------------------------------------- 1 | ## DirSync: PowerShell Commands to Configure Accidental Deletion Functionality (Prevent Accidental Deletes) ## 2 | 3 | #Import the DirSync Module 4 | Import-Module Dirsync 5 | 6 | #Disable the Accidental Deletion Functionality 7 | Set-PreventAccidentalDeletes –Disable 8 | 9 | #Trigger a Full DirSync 10 | Start-OnlineCoexistenceSync -FullSync 11 | 12 | #Enable 13 | Set-PreventAccidentalDeletes -Enable –ObjectDeletionThreshold 500 #Change the threshold value to match your requirements -------------------------------------------------------------------------------- /PowerShell/Working/DirSync/DirSyncStartOnlineCoexistenceSync.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Commandlet to manually start Active Directory Synchronization (Dir Sync) with Office 365 ## 2 | 3 | ## The 'Add-PSSnapin' method was replaced on later DirSync clients with the 'Import-Module' command below 4 | 5 | #Add-PSSnapin "Coexistence-Configuration" -ErrorAction SilentlyContinue 6 | 7 | Import-Module Dirsync 8 | 9 | Start-OnlineCoexistenceSync 10 | 11 | #Start-OnlineCoexistenceSync -FullSync #Use the '-FullSync' parameter to trigger a full sync -------------------------------------------------------------------------------- /PowerShell/Working/FTP/PSFTP/PSFTP.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/FTP/PSFTP/PSFTP.psd1 -------------------------------------------------------------------------------- /PowerShell/Working/FTP/PSFTP/PSFTP.psm1: -------------------------------------------------------------------------------- 1 | Get-ChildItem -Path $PSScriptRoot\*.ps1 | Foreach-Object{ . $_.FullName } 2 | 3 | New-Alias Send-FTPItem Add-FTPItem 4 | New-Alias Receive-FTPItem Get-FTPItem 5 | 6 | Export-ModuleMember -Function * -Alias * -------------------------------------------------------------------------------- /PowerShell/Working/FTP/PSFTP/PowerShellFTPClientModule.txt: -------------------------------------------------------------------------------- 1 | URL: http://gallery.technet.microsoft.com/scriptcenter/PowerShell-FTP-Client-db6fe0cb 2 | 3 | Test FTP Server: 4 | 5 | -- Secure FTP Server Details -- 6 | 7 | Type: FileZilla 8 | 9 | Address: ftp.secureftp-test.com 10 | 11 | Login: test 12 | 13 | Password: test -------------------------------------------------------------------------------- /PowerShell/Working/FTP/PSFTP/Readme.txt: -------------------------------------------------------------------------------- 1 | PowerShell FTP Client Module 2 | The PSFTP module allow you to connect and manage the contents of ftp account. 3 | Module contain set of function to get list of items, download and send files on ftp location. 4 | 5 | Module can be installed manualy by downloading Zip file and extract in two places: 6 | 7 | %USERPROFILE%\Documents\WindowsPowerShell\Modules 8 | %WINDIR%\System32\WindowsPowerShell\v1.0\Modules 9 | 10 | Change Log: 11 | 12 | v1.4 - basic IIS6 compatibility mode 13 | v1.3 - view the contents of directories recursively 14 | v1.2.6 - support for username with '@' 15 | 16 | Available function list: 17 | 18 | Get-FTPChildItem 19 | Get-FTPItem (alias Receive-FTPItem) 20 | Get-FTPItemSize 21 | New-FTPItem 22 | Remove-FTPItem 23 | Rename-FTPItem 24 | Add-FTPItem (alias Send-FTPItem) 25 | Set-FTPConnection 26 | 27 | Sample functions (full content of module in attachment): -------------------------------------------------------------------------------- /PowerShell/Working/Hyper-V/PsHyperV/HyperV/HyperV.psd1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/Hyper-V/PsHyperV/HyperV/HyperV.psd1 -------------------------------------------------------------------------------- /PowerShell/Working/Hyper-V/PsHyperV/PS_Console.REG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/Hyper-V/PsHyperV/PS_Console.REG -------------------------------------------------------------------------------- /PowerShell/Working/Hyper-V/PsHyperV/PShyperv-R2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/Hyper-V/PsHyperV/PShyperv-R2.pdf -------------------------------------------------------------------------------- /PowerShell/Working/Hyper-V/PsHyperV/PsHyperV.txt: -------------------------------------------------------------------------------- 1 | URL: http://pshyperv.codeplex.com 2 | 3 | Build: R2 SP1; Mar 20 2011 -------------------------------------------------------------------------------- /PowerShell/Working/Hyper-V/PsHyperV/install.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | cls 3 | echo Installing PowerShell module for HyperV 4 | echo ============================================= 5 | echo. 6 | echo Ensuring that .Net Framework 2 and Windows PowerShell are installed 7 | Echo Press [ctrl][c] to abort or 8 | pause 9 | 10 | echo It is safe to ignore any Error messages 11 | dism /online /enable-feature /featurename:NetFx2-ServerCore 12 | dism /online /enable-feature /featurename:MicrosoftWindowsPowerShell 13 | 14 | echo. 15 | echo About to create folder and copy Powershell module. 16 | Echo Press [ctrl][c] to abort or 17 | pause 18 | 19 | md "%ProgramFiles%\modules\HyperV" 20 | copy %0\..\HyperV\*.* "%ProgramFiles%\modules\HyperV" 21 | 22 | echo. 23 | echo About to set registry entries for PowerShell script execution, module path and console settings 24 | echo Press [ctrl][c] to abort or 25 | pause 26 | 27 | start /w regedit %0\..\PS_Console.REG 28 | 29 | echo. 30 | echo About to Launch the PowerShell for HyperV 31 | Echo Press [ctrl][c] to abort or 32 | pause 33 | 34 | start %windir%\System32\WindowsPowerShell\v1.0\powershell.exe -noExit -Command "Import-Module '%ProgramFiles%\modules\hyperV' " 35 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Disable-IADObject.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Disable-IADObject 3 | ## Description : Disable a user or computer object in Active Directory. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No Input 7 | ## 8 | ## Output : System.DirectoryServices.DirectoryEntry 9 | ## Usage : 10 | ## 1. Disable computer Server1 11 | ## Get-IADComputer Server1 | Disable-IADObject 12 | ## 13 | ## Notes : 14 | ## Tag : user, computer, activedirectory 15 | ## Change log : 16 | ## ===================================================================== 17 | 18 | 19 | filter Disable-IADObject { 20 | 21 | 22 | 23 | 24 | if($_ -is [ADSI] -and $_.psbase.SchemaClassName -match '^(user|computer)$') 25 | { 26 | $null = $_.psbase.invokeSet("AccountDisabled",$true) 27 | $null = $_.SetInfo() 28 | $_ 29 | } 30 | else 31 | { 32 | Write-Warning "Invalid object type. Only 'User' or 'Computer' objects are allowed." 33 | } 34 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Enable-IADObject.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Enable-IADObject 3 | ## Description : Enable a user or computer object in Active Directory. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No Input 7 | ## 8 | ## Output : System.DirectoryServices.DirectoryEntry 9 | ## Usage : 10 | ## 1. Enable user Test1 11 | ## Get-IADUser Test1 | Enable-IADObject 12 | ## 13 | ## Notes : 14 | ## Tag : user, computer, activedirectory 15 | ## Change log : 16 | ## ===================================================================== 17 | 18 | filter Enable-IADObject { 19 | 20 | 21 | 22 | 23 | if($_ -is [ADSI] -and $_.psbase.SchemaClassName -match '^(user|computer)$') 24 | { 25 | $null = $_.psbase.invokeSet("AccountDisabled",$false) 26 | $null = $_.SetInfo() 27 | $_ 28 | } 29 | else 30 | { 31 | Write-Warning "Invalid object type. Only 'User' or 'Computer' objects are allowed." 32 | } 33 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADAltRecipient.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADAltRecipient 3 | ## Description : Get all objects which has an alternative recipient to receive e-mail 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No Input 7 | ## 8 | ## Output : System.Management.Automation.PSCustomObject 9 | ## Usage : Get-IADAltRecipient | Format-Table Name,Description,AltRecipient -AutoSize 10 | ## 11 | ## Notes : 12 | ## Tag : altrecipient, activedirectory, exchange 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | function Get-IADAltRecipient 17 | { 18 | 19 | $searcher = New-Object System.DirectoryServices.DirectorySearcher 20 | $searcher.SearchRoot = [ADSI]"" 21 | $searcher.PageSize = 1000 22 | $searcher.filter = "(&(sAMAccountType=805306368)(mail=*)(altRecipient=*))" 23 | 24 | $searcher.FindAll() | Foreach-Object { 25 | $pso = "" | select Name,DN,Description,AltRecipient 26 | $pso.Name = [string]$_.Properties.name 27 | $pso.DN = [string]$_.Properties.distinguishedname 28 | $pso.Description = [string]$_.Properties.description 29 | $pso.AltRecipient = [string]$_.Properties.altrecipient 30 | $pso 31 | } 32 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADCurrentDomain.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADCurrentDomain 3 | ## Description : Retrieve current domain information like Domain Controllers, DomainMode, Domain Masters, and Forest Root. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.DirectoryServices.ActiveDirectory.Domain 9 | ## Usage : 10 | ## 1. Retrieve domain FSMO roles holders 11 | ## Get-IADCurrentDomain | Select-Object *owner 12 | ## 13 | ## 2. Retrieve domain controllers for the current domain 14 | ## Get-IADCurrentDomain | Select-Object -ExpandProperty DomainControllers 15 | ## Notes : 16 | ## Tag : domain, activedirectory 17 | ## Change log : 18 | ## ===================================================================== 19 | 20 | 21 | 22 | function Get-IADCurrentDomain { 23 | [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() 24 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADCurrentForest.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADCurrentForest 3 | ## Description : Retrieve current forest information like Domains, Sites, ForestMode, RootDomain, and Forest masters. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.DirectoryServices.ActiveDirectory.Forest 9 | ## Usage : 10 | ## 1. Retrieve the global catalogs information 11 | ## (Get-IADCurrentForest).GlobalCatalogs 12 | ## Notes : 13 | ## Tag : forest, activedirectory 14 | ## Change log : 15 | ## ===================================================================== 16 | 17 | 18 | function Get-IADCurrentForest { 19 | [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() 20 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADDomainController.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADDomainController 3 | ## Description : Retrieve domain controller information. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.Object[] 9 | ## Usage : Get-IADDomainController 10 | ## 11 | ## Notes : 12 | ## Tag : domain, domaincontroller, activedirectory 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | function Get-IADDomainController { 17 | [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().DomainControllers 18 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADDomainController2.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADDomainController2 3 | ## Description : Retrieve domain controllers. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.Object[] 9 | ## Usage : Get-IADDomainController2 -descending 10 | ## 11 | ## Notes : 12 | ## Tag : domain, domaincontroller, activedirectory 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | 17 | function Get-IADDomainController2 { 18 | 19 | param ( 20 | [switch]$descending 21 | 22 | ) 23 | 24 | $domaindn = ([ADSI]"").distinguishedName 25 | $searcher = New-Object System.DirectoryServices.DirectorySearcher 26 | $searcher.searchroot = "LDAP://OU=Domain Controllers,$domaindn" 27 | $searcher.filter = "objectCategory=computer" 28 | $searcher.sort.propertyname = "name" 29 | 30 | if ($descending) 31 | { 32 | $searcher.sort.direction = "Descending" 33 | } 34 | 35 | $searcher.FindAll() | Foreach-Object { $_.GetDirectoryEntry() } 36 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADFSMORoleHolder.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADFSMORoleHolder 3 | ## Description : Retrieve the forest and domain FSMO roles holders. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.Management.Automation.PSCustomObject 9 | ## Usage : Get-IADFSMORoleHolder 10 | ## 11 | ## Notes : 12 | ## Tag : fsmo, forest, domain, activedirectory 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | 17 | 18 | 19 | function Get-IADFSMORoleHolder 20 | { 21 | 22 | $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() 23 | $forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() 24 | 25 | $pso = "" | select Naming,Schema,Pdc,Rid,Infrastructure 26 | 27 | $pso.Naming = $forest.NamingRoleOwner 28 | $pso.Schema = $forest.SchemaRoleOwner 29 | $pso.Pdc = $domain.PdcRoleOwner 30 | $pso.Rid = $domain.RidRoleOwner 31 | $pso.Infrastructure = $domain.InfrastructureRoleOwner 32 | $pso 33 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADGroupMember.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADGroupMember 3 | ## Description : Retrieve the members of a group in Active Directory. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No Input 7 | ## 8 | ## Output : System.DirectoryServices.DirectoryEntry 9 | ## Usage : 10 | ## 1. Retrieve all members of a group TestGroup 11 | ## Get-IADGroup TestGroup | Get-IADGroupMember 12 | ## 13 | ## Notes : 14 | ## Tag : group, member, activedirectory 15 | ## Change log : 16 | ## ===================================================================== 17 | 18 | filter Get-IADGroupMember { 19 | param ( 20 | [switch]$Resolve 21 | ) 22 | 23 | 24 | if($_ -is [ADSI] -and $_.psbase.SchemaClassName -eq 'group') 25 | { 26 | if ($Resolve) { 27 | $_.member |foreach {[ADSI]"LDAP://$_"} 28 | } 29 | else { 30 | $_.member 31 | } 32 | } 33 | else 34 | { 35 | Write-Warning "Invalid object type. Only 'Group' objects are allowed" 36 | } 37 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADObjectBySID.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADObjectBySID 3 | ## Description : Retrieve domain account for known SID. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : Get-IADObjectBySID [[-SID] ] 7 | ## 8 | ## Output : System.String 9 | ## Usage : Get-IADObjectBySID -SID 'S-1-5-21-3889274798-524451202-2197197945-1112' 10 | ## 11 | ## Notes : 12 | ## Tag : security, activedirectory 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | 17 | function Get-IADObjectBySID 18 | { 19 | 20 | param( 21 | [string]$SID 22 | ) 23 | 24 | $si = New-Object System.Security.Principal.SecurityIdentifier $SID 25 | 26 | if($si.IsAccountSid()) 27 | { 28 | $si.Translate([System.Security.Principal.NTAccount]).Value 29 | } 30 | else 31 | { 32 | Write-Error "'$si' is not a valid Windows account SID." 33 | } 34 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADSite.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADSite 3 | ## Description : Retrieve the site(s) information for a forest or current site. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.DirectoryServices.ActiveDirectory.ActiveDirectorySite, System.Object[] 9 | ## Usage : 10 | ## 1. Retrieve current site information 11 | ## Get-IADSite 12 | ## 13 | ## 2. Retrieve all sites in the current forest 14 | ## Get-IADSite -All 15 | ## 16 | ## Notes : 17 | ## Tag : site, activedirectory 18 | ## Change log : 19 | ## ===================================================================== 20 | 21 | 22 | 23 | 24 | 25 | function Get-IADSite { 26 | 27 | 28 | param ( 29 | [switch]$All 30 | ) 31 | 32 | if ($All) 33 | { 34 | [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites 35 | } 36 | else 37 | { 38 | [DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite() 39 | } 40 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADSubnet.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADSubnet 3 | ## Description : Retrieve the subnets in a forest or current site. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.Management.Automation.PSCustomObject 9 | ## Usage : 10 | ## 1. Retrieve all subnets in the current site 11 | ## Get-IADSubnet 12 | ## 13 | ## 2. Retrieve all subnets in the current forest 14 | ## Get-IADSubnet -All 15 | ## Notes : 16 | ## Tag : subnet, site, activedirectory 17 | ## Change log : 18 | ## ===================================================================== 19 | 20 | 21 | function Get-IADSubnet 22 | { 23 | 24 | param ( 25 | [switch]$All 26 | ) 27 | 28 | if ($All) 29 | { 30 | $sites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites 31 | $sites | Select-Object -ExpandProperty Subnets 32 | } 33 | else 34 | { 35 | $currentSite = [DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite() 36 | $currentSite | Select-Object -ExpandProperty Subnets 37 | } 38 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADTombstoneComputer.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADTombstoneComputer 3 | ## Description : Retrieve all deleted computers in Active Directory. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.DirectoryServices.SearchResult 9 | ## Usage : Get-IADTombstoneComputer 10 | ## 11 | ## Notes : 12 | ## Tag : computer, tombstone, deleted, activedirectory 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | 17 | function Get-IADTombstoneComputer 18 | { 19 | $root= New-Object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE") 20 | $searcher = New-Object System.DirectoryServices.DirectorySearcher($root.defaultNamingContext) 21 | $searcher.Filter = "(&(isDeleted=TRUE)(objectClass=User)(samaccountname=*$))" 22 | $searcher.tombstone = $true 23 | $searcher.FindAll() 24 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADTombstoneObject.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADTombstoneObject 3 | ## Description : Retrieve all deleted objects in Active Directory. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.DirectoryServices.SearchResult 9 | ## Usage : Get-IADTombstoneObject 10 | ## 11 | ## Notes : 12 | ## Tag : tombstone, deleted, activedirectory 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | 17 | function Get-IADTombstoneObject 18 | { 19 | 20 | $root= New-Object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE") 21 | $searcher = New-Object System.DirectoryServices.DirectorySearcher($root.defaultNamingContext) 22 | $searcher.Filter = "(&(isDeleted=TRUE))" 23 | $searcher.tombstone = $true 24 | $searcher.FindAll() 25 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ADPowerShellScripts/Get-IADTombstoneUser.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IADTombstoneUser 3 | ## Description : Retrieve all deleted users in Active Directory. 4 | ## Author : Idera 5 | ## Date : 8/11/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.DirectoryServices.SearchResult 9 | ## Usage : Get-IADTombstoneUser 10 | ## 11 | ## Notes : 12 | ## Tag : user, tombstone, deleted, activedirectory 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | function Get-IADTombstoneUser 17 | { 18 | 19 | $root= New-Object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE") 20 | $searcher = New-Object System.DirectoryServices.DirectorySearcher($root.defaultNamingContext) 21 | $searcher.Filter = "(&(isDeleted=TRUE)(objectClass=User)(!(samaccountname=*$)))" 22 | $searcher.tombstone = $true 23 | $searcher.FindAll() 24 | } -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Get-IEXCurrentRole.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IEXCurrentRole 3 | ## Description : Retrieve the role of the currently logged on user. 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : No input 7 | ## 8 | ## Output : Microsoft.Exchange.Management.RecipientTasks.DelegateUser 9 | ## Usage : Get-IEXCurrentRole 10 | ## 11 | ## Notes : 12 | ## Tag : Exchange 2007, role, user, get 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin 17 | 18 | function Get-IEXCurrentRole 19 | { 20 | $user = [Security.Principal.WindowsIdentity]::GetCurrent().Name 21 | Get-ExchangeAdministrator -Identity $user 22 | } 23 | 24 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Get-IEXDatabaseSize.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IEXDatabaseSize 3 | ## Description : Retrieve database size. It must be run on Exchange server. 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : Get-IEXDatabaseSize [[-Server] ] 7 | ## 8 | ## Output : System.Management.Automation.PSCustomObject 9 | ## Usage : 10 | ## 1. Retrieve database size on Exchange server Exch1 11 | ## Get-IEXDatabaseSize -Server Exch1 12 | ## 13 | ## Notes : 14 | ## Tag : Exchange 2007, database, get 15 | ## Change log : 16 | ## ===================================================================== 17 | 18 | 19 | #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin 20 | 21 | function Get-IEXDatabaseSize 22 | { 23 | 24 | param( 25 | [string]$Server=$env:COMPUTERNAME 26 | ) 27 | 28 | 29 | if ((Get-MailboxServer).RedundantMachines) 30 | { 31 | $server = (Get-ClusteredMailboxServerStatus).Identity 32 | } 33 | 34 | $Size = @{Name="Size(MB)";Expression={"{0:N2}" -f ((Get-ChildItem $_.EdbFilePath).Length/1MB)}} 35 | Get-MailboxDatabase -Server $Server | Select-Object Server,Name,StorageGroupName,$Size 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Get-IEXDatabaseStatistics.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IEXDatabaseStatistics 3 | ## Description : Retrieve database info. 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : Get-IEXDatabaseStatistics [[-Server] ] 7 | ## 8 | ## Output : System.Management.Automation.PSCustomObject 9 | ## Usage : Get-IEXDatabaseStatistics -Server Exch1 10 | ## 11 | ## Notes : 12 | ## Tag : Exchange 2007, database, mailbox, get 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | 17 | #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin 18 | 19 | function Get-IEXDatabaseStatistics 20 | { 21 | param( 22 | [string]$Server=$(Throw "parameter 'Server' cannot be empty") 23 | ) 24 | 25 | trap { Throw $_} 26 | 27 | $MbxCount = @{Name="MailboxCount";Expression={ $_.Count }} 28 | $TotalSize = @{Name="TotalSize(GB)";Expression={ "{0:N2}" -f (($_.group | Measure-Object TotalItemSize -Sum).Sum/1GB)}} 29 | 30 | Get-MailboxStatistics -Server $Server | Group-Object Database | Select-Object Name,$MbxCount,$TotalSize 31 | } 32 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Get-IEXEmailAddressReport.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IEXEmailAddressReport 3 | ## Description : Enumerate email addresses 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.Management.Automation.PSCustomObject 9 | ## Usage : 10 | ## 1. Enumerate email addresses per user 11 | ## Get-IEXEmailAddressReport -Server ExchangeServerName 12 | ## 13 | ## Notes : 14 | ## Tag : Exchange 2007, mailbox, email address, get 15 | ## Change log : 16 | ## ===================================================================== 17 | 18 | #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin 19 | 20 | function Get-IEXEmailAddressReport 21 | { 22 | 23 | param( 24 | [string]$Server = $(Throw 'Please, specify a server name.'), 25 | [Microsoft.Exchange.Configuration.Tasks.OrganizationalUnitIdParameter]$OrganizationalUnit = $null 26 | ) 27 | 28 | Get-Mailbox -ResultSize unlimited -Server $Server -OrganizationalUnit $OrganizationalUnit | Select-Object DisplayName -ExpandProperty EmailAddresses | Where-Object {$_.SmtpAddress} | Select-Object DisplayName,SmtpAddress 29 | 30 | } 31 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Get-IEXForwardMailbox.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IEXForwardMailbox 3 | ## Description : List users with email forwarding enabled (with or without delivering a copy to the original recipient) 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : No input 7 | ## 8 | ## Output : System.Management.Automation.PSCustomObject 9 | ## Usage : 10 | ## 1. List users with email forwarding enabled (with or without delivering a copy to the original recipient) 11 | ## Get-IEXForwardMailbox 12 | ## 13 | ## Notes : 14 | ## Tag : Exchange 2007, mailbox, filter, forward, get 15 | ## Change log : 16 | ## ===================================================================== 17 | 18 | #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin 19 | 20 | function Get-IEXForwardMailbox 21 | { 22 | Get-Mailbox -Filter {ForwardingAddress -ne $null} | Select-Object Name,ForwardingAddress,DeliverToMailboxAndForward 23 | } 24 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Get-IEXMailboxAddressCount.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IEXMailboxAddressCount 3 | ## Description : Get email addresses count for all users. 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : No input 7 | ## 8 | ## Output : Microsoft.Exchange.Data.Directory.Management.Mailbox 9 | ## Usage : 10 | ## 1. Get email addresses count for all users, use Format-Table to alter results. 11 | ## Get-IEXMailboxAddressCount | Format-Table Name,@{Label="AddressCount";Expression={$_.EmailAddresses.Count}} 12 | ## 13 | ## Notes : 14 | ## Tag : Exchange 2007, email, user, get, mailbox 15 | ## Change log : 16 | ## ===================================================================== 17 | 18 | 19 | #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin 20 | 21 | 22 | function Get-IEXMailboxAddressCount 23 | { 24 | Get-Mailbox -resultSize unlimited | Where-Object {$_.EmailAddresses.count -gt 1} 25 | } 26 | 27 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Get-IEXMailboxCountReport.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IEXMailboxCountReport 3 | ## Description : Get mailbox count per mailbox database 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : Get-IEXMailboxCountReport [[-Server] ] 7 | ## 8 | ## Output : Microsoft.PowerShell.Commands.GroupInfo 9 | ## Usage : 10 | ## 1. Get mailbox count per mailbox database on server ExchangeServerName 11 | ## Get-IEXMailboxCountReport -Server ExchangeServerName 12 | ## 13 | ## Notes : 14 | ## Tag : Exchange 2007, mailbox, get 15 | ## Change log : 16 | ## ===================================================================== 17 | 18 | #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin 19 | 20 | 21 | function Get-IEXMailboxCountReport{ 22 | param( 23 | [string]$Server = $(Throw 'Please specify a server name.') 24 | ) 25 | 26 | Get-Mailbox -Server $Server | Group-Object {$_.Database.Name} -NoElement | Sort-Object -Property Count -Descending 27 | } 28 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Get-IEXSendAsPermission.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-IEXSendAsPermission 3 | ## Description : Retrieve the users that have "Send As" permission. 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : Get-IEXSendAsPermission [[-Server] ] [-Inherited] 7 | ## 8 | ## Output : Microsoft.Exchange.Management.RecipientTasks.ADAcePresentationObject 9 | ## Usage : 10 | ## 1. Retrieve the users that have "Send As" permission. 11 | ## Get-IEXSendAsPermission -Server Exch1 | Select-Object Identity,User 12 | ## 13 | ## Notes : 14 | ## Tag : Exchange 2007, mailbox, permission, get 15 | ## Change log : 16 | ## ===================================================================== 17 | 18 | 19 | #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin 20 | 21 | function Get-IEXSendAsPermission 22 | { 23 | param( 24 | 25 | 26 | [string]$Server = $(Throw 'Please, specify a server name.'), 27 | 28 | [switch]$Inherited 29 | ) 30 | 31 | Get-Mailbox -ResultSize Unlimited -Server $server | Get-ADPermission | Where-Object { ($_.ExtendedRights -like "*Send-As*") -AND ($_.IsInherited -eq $Inherited) -AND ($_.User -notlike "*NT AUTHORITY\SELF*") } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Test-IEXDistinguishedName.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Test-IEXDistinguishedName 3 | ## Description : Check the validity of distinguished name string. 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : Test-IEXDistinguishedName [[-dn] ] 7 | ## 8 | ## Output : System.Boolean 9 | ## Usage : Test-IEXDistinguishedName "OU=DisabledUsers,DC=domain,DC=com" 10 | ## 11 | ## Notes : 12 | ## Tag : Exchange 2007, distinguished name, validity, .NET Framework, test 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | 17 | #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin 18 | 19 | function Test-IEXDistinguishedName 20 | { 21 | param( 22 | [string]$dn 23 | ) 24 | 25 | [Microsoft.Exchange.Data.Directory.ADObjectId]::IsValidDistinguishedName($dn) 26 | } 27 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Test-IEXEmailAddress.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Test-IEXEmailAddress 3 | ## Description : Check the validity of an email address. Returns $true for all valid email addresses, otherwise $false. 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : Test-IEXEmailAddress [[-EmailAddress] ] 7 | ## 8 | ## Output : System.Boolean 9 | ## Usage : 1. Test email address user@domain.local 10 | ## Test-EmailAddress -EmailAddress user@domain.local 11 | ## Notes : 12 | ## Tag : Exchange 2007, email address, validity, .NET Framework, test 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | 17 | #requires -pssnapin Microsoft.Exchange.Management.PowerShell.Admin 18 | 19 | 20 | function Test-IEXEmailAddress 21 | { 22 | param( 23 | [string]$EmailAddress=$(throw "EmailAddress cannot be empty.") 24 | ) 25 | 26 | ![Microsoft.Exchange.Data.SmtpProxyAddress]::Parse($EmailAddress).ParseException 27 | } 28 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_ExchangeScripts/Test-IEXEmailAddress2.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Test-IEXEmailAddress2 3 | ## Description : Check the validity of an email address. Returns $true for all valid email addresses, otherwise $false. 4 | ## Author : Idera 5 | ## Date : 09/15/2009 6 | ## Input : Test-IEXEmailAddress2 [[-EmailAddress] ] 7 | ## 8 | ## Output : System.Boolean 9 | ## Usage : 10 | ## 1. Test email address user2@domain.local 11 | ## Test-EmailAddress2 -EmailAddress user2@domain.local 12 | ## Notes : 13 | ## Tag : email address, validity, .NET Framework, test 14 | ## Change log : 15 | ## ===================================================================== 16 | 17 | 18 | function Test-IEXEmailAddress2 19 | 20 | { 21 | param ( 22 | [string]$EmailAddress=$(throw "EmailAddress cannot be empty.") 23 | ) 24 | 25 | ($EmailAddress -as [System.Net.Mail.MailAddress]).Address -eq $EmailAddress -and $EmailAddress -ne $null 26 | } 27 | 28 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_PowerShellPlus/IderaPowerShellPlusInstallationKit-x64.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/IderaPowerShellScripts/Idera_PowerShellPlus/IderaPowerShellPlusInstallationKit-x64.zip -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_PowerShellPlus/IderaPowerShellPlusInstallationKit.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/IderaPowerShellScripts/Idera_PowerShellPlus/IderaPowerShellPlusInstallationKit.zip -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2005/Load-MSSQL-SMO.ps1: -------------------------------------------------------------------------------- 1 | # Load-MSSQL-SMO.ps1 2 | # 3 | 4 | [void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.ConnectionInfo" ); 5 | [void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.SqlEnum" ); 6 | [void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.SmoEnum" ); 7 | [void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.Smo" ); -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2005/Readme.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2005/Readme.doc -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2005/Readme.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2005/Readme.pdf -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2005/SampleData.csv: -------------------------------------------------------------------------------- 1 | Field1,Field2,Field3 2 | 1,AR-5381,Adjustable Race 3 | 3,BE-2349,BB Ball Bearing 4 | 850,SH-M897-L,"Men's Sports Shorts, L" 5 | 316,BL-2036,Blade 6 | 317,CA-5965,LL Crankarm 7 | 318,CA-6738,ML Crankarm 8 | 319,CA-7457,HL Crankarm 9 | 320,CB-2903,Chainring Bolts 10 | 321,CN-6137,Chainring Nut 11 | 322,CR-7833,Chainring 12 | 323,CR-9981,Crown Race 13 | 324,CS-2812,Chain Stays 14 | 325,DC-8732,Decal 1 15 | 326,DC-9824,Decal 2 16 | 327,DT-2377,Down Tube 17 | 328,EC-M092,Mountain End Caps 18 | 329,EC-R098,Road End Caps 19 | 330,EC-T209,Touring End Caps 20 | 331,FE-3760,Fork End 21 | 332,FH-2981,Freewheel 22 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2005/Start-SQLServerService.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Start-SQLServerService 3 | ## Description : Start SQL Server service for default instance 4 | ## Author : Idera 5 | ## Date : 6/27/2008 6 | ## Input : -service .\Start-SQLServerService -service MSSQLServer -verbose -debug 11 | ## Notes : 12 | ## Tag : 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | param 17 | ( 18 | [string]$service = "MSSQLServer", 19 | [switch]$verbose, 20 | [switch]$debug 21 | ) 22 | 23 | function main() 24 | { 25 | if ($verbose) {$VerbosePreference = "Continue"} 26 | if ($debug) {$DebugPreference = "Continue"} 27 | Start-SQLServerService $service 28 | } 29 | 30 | function Start-SQLServerService() 31 | { 32 | Start-Service $service 33 | Write-Host "$service service started" 34 | } 35 | 36 | main -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2005/Stop-SQLServerService.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Stop-SQLServerService 3 | ## Description : Stop SQL Server service for default instance 4 | ## Author : Idera 5 | ## Date : 6/27/2008 6 | ## Input : -service .\Stop-SQLServerService -service MSSQLServer -verbose -debug 11 | ## Notes : service 12 | ## Tag : 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | param 17 | ( 18 | [string]$service = "MSSQLServer", 19 | [switch]$verbose, 20 | [switch]$debug 21 | ) 22 | 23 | function main() 24 | { 25 | if ($verbose) {$VerbosePreference = "Continue"} 26 | if ($debug) {$DebugPreference = "Continue"} 27 | Stop-SQLServerService $service 28 | } 29 | 30 | function Stop-SQLServerService() 31 | { 32 | Stop-Service $service -Force 33 | Write-Host "$service service stopped" 34 | } 35 | 36 | main -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2008/Load-MSSQL-SMO.ps1: -------------------------------------------------------------------------------- 1 | # Load-MSSQL-SMO.ps1 2 | # 3 | 4 | [void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.Management.Common" ); 5 | [void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.SmoEnum" ); 6 | [void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.Smo" ); 7 | [void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.SmoExtended " ); 8 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2008/Readme.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2008/Readme.doc -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2008/Readme.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2008/Readme.pdf -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2008/SampleData.csv: -------------------------------------------------------------------------------- 1 | Field1,Field2,Field3 2 | 1,AR-5381,Adjustable Race 3 | 3,BE-2349,BB Ball Bearing 4 | 850,SH-M897-L,"Men's Sports Shorts, L" 5 | 316,BL-2036,Blade 6 | 317,CA-5965,LL Crankarm 7 | 318,CA-6738,ML Crankarm 8 | 319,CA-7457,HL Crankarm 9 | 320,CB-2903,Chainring Bolts 10 | 321,CN-6137,Chainring Nut 11 | 322,CR-7833,Chainring 12 | 323,CR-9981,Crown Race 13 | 324,CS-2812,Chain Stays 14 | 325,DC-8732,Decal 1 15 | 326,DC-9824,Decal 2 16 | 327,DT-2377,Down Tube 17 | 328,EC-M092,Mountain End Caps 18 | 329,EC-R098,Road End Caps 19 | 330,EC-T209,Touring End Caps 20 | 331,FE-3760,Fork End 21 | 332,FH-2981,Freewheel 22 | -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2008/Start-SQLServerService.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Start-SQLServerService 3 | ## Description : Start SQL Server service for default instance 4 | ## Author : Idera 5 | ## Date : 6/27/2008 6 | ## Input : -service .\Start-SQLServerService -service MSSQLServer -verbose -debug 11 | ## Notes : 12 | ## Tag : 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | param 17 | ( 18 | [string]$service = "MSSQLServer", 19 | [switch]$verbose, 20 | [switch]$debug 21 | ) 22 | 23 | function main() 24 | { 25 | if ($verbose) {$VerbosePreference = "Continue"} 26 | if ($debug) {$DebugPreference = "Continue"} 27 | Start-SQLServerService $service 28 | } 29 | 30 | function Start-SQLServerService() 31 | { 32 | Start-Service $service 33 | Write-Host "$service service started" 34 | } 35 | 36 | main -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SQLServerScripts/SQL Server 2008/Stop-SQLServerService.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Stop-SQLServerService 3 | ## Description : Stop SQL Server service for default instance 4 | ## Author : Idera 5 | ## Date : 6/27/2008 6 | ## Input : -service .\Stop-SQLServerService -service MSSQLServer -verbose -debug 11 | ## Notes : service 12 | ## Tag : 13 | ## Change log : 14 | ## ===================================================================== 15 | 16 | param 17 | ( 18 | [string]$service = "MSSQLServer", 19 | [switch]$verbose, 20 | [switch]$debug 21 | ) 22 | 23 | function main() 24 | { 25 | if ($verbose) {$VerbosePreference = "Continue"} 26 | if ($debug) {$DebugPreference = "Continue"} 27 | Stop-SQLServerService $service 28 | } 29 | 30 | function Stop-SQLServerService() 31 | { 32 | Stop-Service $service -Force 33 | Write-Host "$service service stopped" 34 | } 35 | 36 | main -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SharePointScripts/Display-SPList.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Display-SPList 3 | ## Description : Displays All Lists 4 | ## Author : Idera 5 | ## Date : 24/11/2009 6 | ## Input : Display-SPList [[-url] ] 7 | ## Output : 8 | ## Usage : Display-SPList -url http://moss 9 | ## Notes : Adapted From Niklas Goude Script 10 | ## Tag : List, Sharepoint, Powershell 11 | ## Change log : 12 | ## ===================================================================== 13 | 14 | param ( 15 | 16 | [string]$url = "$(Read-Host 'url [e.g. http://moss]')" 17 | ) 18 | 19 | function main() { 20 | 21 | [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 22 | 23 | Display-SPList -url $url 24 | } 25 | 26 | function Get-SPSite([string]$url) { 27 | 28 | New-Object Microsoft.SharePoint.SPSite($url) 29 | } 30 | 31 | function Get-SPWeb([string]$url) { 32 | 33 | $SPSite = Get-SPSite $url 34 | return $SPSite.OpenWeb() 35 | $SPSite.Dispose() 36 | } 37 | 38 | function Display-SPList([string]$url) { 39 | 40 | $OpenWeb = Get-SPWeb $url 41 | 42 | $OpenWeb.Lists | Select Title, ItemCount,Description 43 | 44 | $OpenWeb.Dispose() 45 | } 46 | 47 | main -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SharePointScripts/Get-SPWeb.ps1: -------------------------------------------------------------------------------- 1 | ## ===================================================================== 2 | ## Title : Get-SPWeb 3 | ## Description : Gets a SP WebSite 4 | ## Author : Idera 5 | ## Date : 24/11/2009 6 | ## Input : Get-SPWeb [[-url] ] 7 | ## Output : 8 | ## Usage : Get-SPWeb -url http://moss 9 | ## Notes : Adapted From Niklas Goude Script 10 | ## Tag : Site, Sharepoint, Powershell 11 | ## Change log : 12 | ## ===================================================================== 13 | 14 | param ( 15 | 16 | [string]$url = "$(Read-Host 'url [e.g. http://moss]')" 17 | ) 18 | 19 | function main() { 20 | 21 | [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 22 | 23 | Get-SPWeb -url $url 24 | } 25 | 26 | function Get-SPSite([string]$url) { 27 | 28 | New-Object Microsoft.SharePoint.SPSite($url) 29 | } 30 | 31 | function Get-SPWeb([string]$url) { 32 | 33 | $SPSite = Get-SPSite $url 34 | return $SPSite.OpenWeb() 35 | $SPSite.Dispose() 36 | } 37 | 38 | main -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SharePointScripts/Readme.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/IderaPowerShellScripts/Idera_SharePointScripts/Readme.doc -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SharePointScripts/Readme.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/IderaPowerShellScripts/Idera_SharePointScripts/Readme.pdf -------------------------------------------------------------------------------- /PowerShell/Working/IderaPowerShellScripts/Idera_SharePointScripts/Set-SPItem.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/IderaPowerShellScripts/Idera_SharePointScripts/Set-SPItem.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/LogParser/ProtocolStatusQuery.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Using PowerShell To Run Log Parser Queries ## 2 | ## Overview: The Script below is an example of how you can use Log Parser with PowerShell to query IIS logs for Protocol Status messages 3 | ## Requirements: Needs Log Parser 2.2 installed on the machine you run the script from 4 | ## Usage Example: ./ProtocolStatusQuery.ps1 "\\ServerName\d$\Logs\IIS\*.log" 5 | 6 | $iisfiles = dir $args[0] #Variable for the IIS log files 7 | #The 2 variables below make use of the LogParser COM Object 8 | $m = New-Object -comobject MSUtil.LogQuery 9 | $pif = New-Object -comobject MSUtil.LogQuery.IISW3CInputFormat 10 | 11 | foreach ($iisfile in $iisfiles) 12 | { 13 | 14 | $SQL = "select DISTINCT cs-username, date, cs-uri-stem, sc-status from $iisfile where (sc-status >= 500 AND sc-status < 600) AND (cs-uri-stem LIKE '%.ASPX') " 15 | $recordSet = $m.Execute($SQL, $pif) 16 | 17 | "DATE USER URL STATUS" 18 | "=====================================================================" 19 | for(; !$recordSet.atEnd(); $recordSet.moveNext()) 20 | { 21 | $record=$recordSet.getRecord(); 22 | write-host ($record.GetValue(“date”).toshortdatestring() + “--” + $record.GetValue(“cs-username”) + “--” + $record.GetValue(“cs-uri-stem”) + “--”+ $record.GetValue(“sc-status”)); 23 | } 24 | 25 | $recordSet.Close(); 26 | 27 | } -------------------------------------------------------------------------------- /PowerShell/Working/PSRemoting/EncryptCredentialsForPSRemoting.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell Script to store and use the same credentials for PSRemoting scripting ## 2 | 3 | # Set your PowerShell Variables here 4 | 5 | $PasswordFileLocation = "C:\FolderName\psremotingpassword.txt" #Change the path here to suit your environment 6 | $PSRemotingUser = "DOMAIN\User" #Change the domain and user here to suit your environment 7 | $RemoteMachine = "MachineName" #Change the remote machine name here to suit your environment 8 | 9 | # Get host input to encrypt PSRemoting password to an encrypted text file 10 | 11 | Read-Host "Please enter your PSRemoting password" -AsSecureString | ConvertFrom-SecureString | out-file $PasswordFileLocation 12 | 13 | # Now read the PSRemoting password to a SecureString 14 | 15 | $pwd = Get-Content $PasswordFileLocation | ConvertTo-SecureString 16 | 17 | # Now create the credential to be used 18 | 19 | $crd = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $PSRemotingUser,$pwd 20 | 21 | # Now use your credentials for a new PSRemoting session 22 | 23 | Enter-PSSession -ComputerName $RemoteMachine -Authentication CredSSP -Credential $crd -------------------------------------------------------------------------------- /PowerShell/Working/SQLServer/SQLClusterFailoverTest.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script to Test SQL Server Clusters For Failover ## 2 | 3 | Import-Module FailoverClusters; 4 | 5 | # Set cluster name 6 | $cluster = "Cluster"; 7 | 8 | # Date stamp used for report name 9 | $date = Get-Date -Format "yyyyMMdd"; 10 | 11 | # Take cluster services offline. You may need to customise this 12 | # according to your specific needs 13 | Stop-ClusterGroup -Cluster $cluster -Name "ClusterDtc"; 14 | Stop-ClusterGroup -Cluster $cluster -Name "SQL Server (MSSQLSERVER)"; 15 | 16 | # Test Cluster 17 | Test-Cluster -Cluster $cluster -ReportName "$date"; 18 | 19 | # Bring services back online 20 | Start-ClusterGroup -Cluster $cluster -Name "ClusterDtc"; 21 | Start-ClusterGroup -Cluster $cluster -Name "SQL Server (MSSQLSERVER)"; 22 | 23 | -------------------------------------------------------------------------------- /PowerShell/Working/SQLServer/SQLPS/GetMAXDOP.ps1: -------------------------------------------------------------------------------- 1 | #Gets the SQL MAXDOP running value and outputs to a given file 2 | param 3 | ( 4 | [String]$OutputFile 5 | ) 6 | 7 | Add-PSSnapin SqlServerCmdletSnapin100 -EA 0 8 | 9 | #Get the MAXDOP setting and output to a file 10 | Invoke-sqlcmd -Query 'sp_configure "max degree of parallelism"' | Format-List | Out-File -filePath $OutputFile -------------------------------------------------------------------------------- /PowerShell/Working/SQLServer/SQLPS/GetSQLConfigInfo.ps1: -------------------------------------------------------------------------------- 1 | #Gets the general config settings for SQL 2 | param 3 | ( 4 | [String]$OutputFile 5 | ) 6 | 7 | Add-PSSnapin SqlServerCmdletSnapin100 -EA 0 8 | 9 | #Get the setting and output to a file 10 | Invoke-sqlcmd -Query 'exec sp_configure' | Format-List | Out-File -filePath $OutputFile -------------------------------------------------------------------------------- /PowerShell/Working/SQLServer/SQLPS/GetSQLServerCores.ps1: -------------------------------------------------------------------------------- 1 | #Gets the number of CPU Cores and TempDB datafiles outputs to a given file 2 | #Adapted from: http://www.sqlskills.com/BLOGS/PAUL/post/Survey-how-is-your-tempdb-configured.aspx 3 | param 4 | ( 5 | [String]$OutputFile 6 | ) 7 | 8 | Add-PSSnapin SqlServerCmdletSnapin100 -EA 0 9 | 10 | #SQL query to pass to Invoke-sqlcms 11 | $sqlquery = "SELECT os.Cores, df.Files FROM (SELECT COUNT(*) AS Cores FROM sys.dm_os_schedulers WHERE status = 'VISIBLE ONLINE') AS os, (SELECT COUNT(*) AS Files FROM tempdb.sys.database_files WHERE type_desc = 'ROWS') AS df;" 12 | 13 | #Get the values and output to a file 14 | Invoke-sqlcmd -Query $sqlquery | Format-List | Out-File -filePath $OutputFile -------------------------------------------------------------------------------- /PowerShell/Working/SQLServer/SQLPS/Readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SQLServer/SQLPS/Readme.txt -------------------------------------------------------------------------------- /PowerShell/Working/SQLServer/SQLPS/SQLOutGridViewQueryFunction.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script that uses SQL Server PowerShell Module (SQLPS) Function to Query a SQL Instance with Grid View Output (Out-GridView) ## 2 | 3 | ## Overview: Function that uses SQL Server PowerShell Module (SQLPS) Query (Invoke-Sqlcmd) to query a SQL Instance and provides the results in Out-GridView format 4 | 5 | ## Requires: SQL Server PowerShell Module (SQLPS) on remote clients 6 | 7 | ## Usage: Edit the parameters in the 'Out-SqlGrid' function to match your requirements and run the script 8 | 9 | #Import SQL Server module 10 | Import-Module SQLPS -DisableNameChecking 11 | 12 | function Out-SqlGrid( 13 | [string]$query="EXEC sp_databases", #Copy your SQL query here, and ensure it remains between the double qoutations "" 14 | [string]$title=$query, 15 | [string]$ServerInstance="SQLINSTANCENAME", #Provide your SQL Instance here 16 | [string]$Database="master" #Provide your Database name here 17 | ) 18 | { 19 | Invoke-Sqlcmd -ServerInstance $ServerInstance -Database $Database -Query $query | Out-GridView -Title $title 20 | } 21 | 22 | #Call the function 23 | Out-SqlGrid -------------------------------------------------------------------------------- /PowerShell/Working/SQLServer/SQLPS/SQLPowerShell.txt: -------------------------------------------------------------------------------- 1 | URLs: 2 | 3 | http://blogs.msdn.com/b/aaronsaikovski/archive/2011/09/16/useful-sql-powershell-scripts.aspx 4 | 5 | https://skydrive.live.com/?cid=17444de481aa42ac&id=17444DE481AA42AC!801#cid=17444DE481AA42AC&id=17444DE481AA42AC!801 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PowerShell/Working/SQLServer/SQLServerConnectAndRunQueriesFromTextFile.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Function To Run a SQL Query From A Text File And Output The Results To HTML ## 2 | 3 | function SQLQueryHTMLOutput 4 | { 5 | $sqlConnection = new-object System.Data.SqlClient.SqlConnection "server=YourInstance;database=msdb;Integrated Security=sspi" #Change the SQL Instance to suit your environment 6 | $sqlConnection.Open() 7 | $sqlCommand = New-object system.data.sqlclient.SqlCommand 8 | $sqlCommand.CommandTimeout = 30 9 | $sqlCommand.Connection = $sqlConnection 10 | $sqlCommand.CommandText = get-content "C:\Scripts\PowerShell\SQL_Query.txt" # Change your path and file name details here 11 | $sqlDataAdapter = new-object System.Data.SqlClient.SQLDataAdapter($sqlCommand) 12 | $sqlDataSet = new-object System.Data.dataset 13 | $sqlDataAdapter.fill($sqlDataSet) 14 | $sqlDataSet.tables[0].select() 15 | } 16 | 17 | #Example: 18 | SQLQueryHTMLOutput | ConvertTo-HTML -title "Your Title here" -head "" | Out-File "C:\Scripts\PowerShell\QueryReport.html" # Change your path and file name details here 19 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/GetSharePointOrphanedUsers.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/MOSS2007/GetSharePointOrphanedUsers.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007CompareFilesAndFolders.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Commands To Compare Files And Folders Between Servers ## 2 | ## Usage: Can be used for comparing 'FEATURES' and other directories 3 | ## Compare-Object PowerShell commandlet can be used for any other files and folders - not just SharePoint 4 | 5 | $Server1 = Dir "\\spcharon1\c$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES" 6 | $Server2 = Dir "\\spleda3\c$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES" 7 | 8 | Compare-Object $Server1 $Server2 9 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007DeleteAllRecycleBinItems.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Function to Clear All Recycle Bin Items ## 2 | 3 | # Overview: Clear all Recycle Bin Items for a site collection (Both Recycle Bin Stages) 4 | # Environments: MOSS 2007, and SharePoint Server 2010 / 2013 Farms 5 | # Function: Clear-All-RecycleBin 6 | # Parameters: SiteCollectionURL : URL for Site Collection 7 | # Usage Example: Clear-All-RecycleBin "http://myWebApplication/sites/mySiteCollection/" 8 | 9 | function Clear-All-RecycleBin([string]$SiteCollectionURL) 10 | { 11 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null 12 | $site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL) 13 | Write-Host "SiteCollectionURL", $SiteCollectionURL 14 | 15 | $SitecollectionRecycleBin = $site.RecycleBin 16 | Write-Host "SitecollectionRecycleBin Number", $SitecollectionRecycleBin.Count 17 | 18 | for ($x = $SitecollectionRecycleBin.Count ; $x -gt 0 ; $x--) 19 | { 20 | $Item = $SitecollectionRecycleBin.Item($x-1) 21 | $SitecollectionRecycleBin.Delete($Item.ID) 22 | } 23 | Write-Host "SitecollectionRecycleBin Number", $SitecollectionRecycleBin.Count 24 | } 25 | 26 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007DeleteAuditDataTableRecords.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: Powershell Script to delete AuditData Table Records ## 2 | # Overview: PowerShell script built on the stsadm -o trimauditlog command 3 | # Environments: MOSS 2007 Farms 4 | # Usage: Edit the following two variable to suit your requirements and run the script: '$constantNumberDays', '$newSTSADM2' 5 | # Resource: http://surfpointtech.com/2012/02/01/sharepoint-auditdata-table-is-too-large-powershell-script-to-schedule-stsadm-o-trimauditlog 6 | 7 | $currentDate = Get-Date 8 | #Write-Host $currentDate 9 | 10 | #Subtract number of days to sync up to the last day we want to keep in the table 11 | $constantNumberDays = -365 #Change the number of days to suite your requirements 12 | 13 | $newDateToDelete = $currentDate.AddDays($constantNumberDays) 14 | 15 | $newDateString = '{0:yyyyMMdd}' -f $newDateToDelete 16 | #Write-Host $newDateString 17 | 18 | $newSTSADM1 = "stsadm -o trimauditlog -date " 19 | $newSTSADM2 = " -databasename WSS_Content" #Change your content database name here 20 | $newSTSADMFinal = "$newSTSADM1$newDateString$newSTSADM2" 21 | 22 | invoke-expression "$newSTSADMFinal" -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007DisableDocumentParserProcessing.ps1: -------------------------------------------------------------------------------- 1 | ## MOSS 2007: PowerShell Script To Enable Or Disable Document Parser Processing ## 2 | ## Overview: http://msdn.microsoft.com/en-us/library/aa543341(v=office.12).aspx 3 | 4 | param($url=$(Throw "Parameter missing: -url"), $switch=$(Throw "Parameter missing (on/off): -switch")) 5 | "URL -> $url, switch-> $switch" 6 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint"); 7 | $site = New-Object Microsoft.SharePoint.SPSite($url); 8 | 9 | $enabled = $true; 10 | if ($switch -match "off") {$enabled=$false}; 11 | 12 | 13 | "Current RootWeb Setting: "+$site.RootWeb.ParserEnabled; 14 | $site.RootWeb.ParserEnabled = $enabled; 15 | #$site.RootWeb.AllowUnsafeUpdates = $true; 16 | $site.RootWeb.Update(); 17 | $site = New-Object Microsoft.SharePoint.SPSite($url); 18 | "After RootWeb Setting: "+$site.RootWeb.ParserEnabled; 19 | 20 | # Example Command of setting the $site.RootWeb.ParserEnabled value to off / false: 21 | 22 | #.\SP2007DisableDocumentParserProcessing.ps1 -url "http://YourSharePointSite.com" off 23 | 24 | # Example Command of setting the $site.RootWeb.ParserEnabled value to on / true: 25 | 26 | #.\SP2007DisableDocumentParserProcessing.ps1 -url "http://YourSharePointSite.com" on -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007EnumerateListItems.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/MOSS2007/SP2007EnumerateListItems.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007FixUpgradeIssues.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/MOSS2007/SP2007FixUpgradeIssues.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007GetAllFeaturesOnFilePath.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: Using PowerShell to list all Feature IDs and Feature Titles on a File System Path ## 2 | 3 | # Specify the directory path/s where your features are that you want to list 4 | 5 | # For SharePoint / MOSS 2007 6 | 7 | cd "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES" 8 | 9 | # For SharePoint Server 2010 10 | 11 | #cd "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES" 12 | 13 | # For SharePoint Server 2013 14 | 15 | #cd "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\FEATURES" 16 | 17 | gci -recurse -filter feature.xml | % { $contents=get-content $_.fullname; $x=[XML]$contents; "{0} {1}" -f $x.Feature.Id, $x.feature.title } 18 | 19 | # To output this to a file 20 | 21 | #gci -recurse -filter feature.xml | % { $contents=get-content $_.fullname; $x=[XML]$contents; "{0} {1}" -f $x.Feature.Id, $x.feature.title } > "C:\BoxBuild\Scripts\PowerShell\Features_On_Disk.txt" -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007GetFarmID.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: Determine Your Farm ID With PowerShell ## 2 | 3 | ## Environments: Works on MOSS 2007 and SharePoint Server 2010 Farms 4 | 5 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 6 | $spFarm=[Microsoft.SharePoint.Administration.SPfarm]::Local 7 | $spFarm.Id 8 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007HideListField.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Function To Hide And Unhide SharePoint List Fields ## 2 | ## Resource: http://www.powershell.nu/2009/01/13/hiding-a-listfield-in-newformeditform-in-sharepoint 3 | ## Usage: Works on both MOSS 2007 and SharePoint Server 2010 Farms 4 | 5 | function Hide-SPField([string]$url, [string]$List, [string]$Field) { 6 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 7 | 8 | $SPSite = New-Object Microsoft.SharePoint.SPSite($url) 9 | $OpenWeb = $SPSite.OpenWeb() 10 | 11 | $OpenList = $OpenWeb.Lists[$List] 12 | 13 | $OpenField = $OpenList.Fields[$Field] 14 | $OpenField.ShowInNewForm = $False #Change this value to '$True' if you want the field to be visible again 15 | $OpenField.ShowInEditForm = $False #Change this value to '$True' if you want the field to be visible again 16 | $OpenField.Update() 17 | 18 | $SPSite.Dispose() 19 | $OpenWeb.Dispose() 20 | } 21 | 22 | #Example: 23 | 24 | #Hide-SPField -url "http://moss/site" -List "My Custom List" -Field "UserField" -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007MigrateUser.ps1: -------------------------------------------------------------------------------- 1 | # FileName: spMigrateUser.ps1 2 | # Name: spMigrateUser.ps1 3 | # Version: 1.0 4 | # Author: Lognoul Marc (lognoulm@hotmail.com) 5 | # Description: Reproduces the behavior of the command STSADM -o migrateuser. More added value to come (batch migration and subsequent updates. 6 | # Tested with: Windows 2003 SP3, Windows 2008 SP2, WSS SP2, MOSS SP2 7 | # Dependencies: Assemblies Microsoft.SharePoint and Microsoft.SharePoint.Administration 8 | 9 | [Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 10 | [Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") 11 | 12 | $OldLogin = "DOMAIN\USER" 13 | $NewLogin = "DOMAIN\USER" 14 | $EnforceSidHistory = $False 15 | 16 | $spFarm = [Microsoft.SharePoint.Administration.SPfarm]::Local 17 | $spFarm.MigrateUserAccount($OldLogin, $NewLogin, $EnforceSidHistory) -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/SP2007ShowListFields.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Show All Fields In A List (Includes Custom and System Fields) ## 2 | ## Resource: http://allaboutmoss.com/2010/05/11/3-ways-to-find-sharepoint-list-fields-internal-name 3 | ## Environments: MOSS 2007 and SharePoint Server 2010 4 | 5 | [system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint") 6 | $site= New-Object Microsoft.SharePoint.SPSite ("http://YourSPSite") #Change this to suit your environment 7 | $web=$site.OpenWeb() 8 | $list=$web.Lists["TestCustomList"] #Change this to your list name 9 | $list.Fields |select title, internalname| more -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/powershell.nu_moss2007_script_collection/Add-SPAnnouncement.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/MOSS2007/powershell.nu_moss2007_script_collection/Add-SPAnnouncement.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/powershell.nu_moss2007_script_collection/Get-SPSite.ps1: -------------------------------------------------------------------------------- 1 | ################################################################################## 2 | # 3 | # 4 | # Script name: Get-SPSite.ps1 5 | # 6 | # Author: niklas.goude@zipper.se 7 | # Homepage: www.powershell.nu 8 | # Company: www.zipper.se 9 | # 10 | ################################################################################## 11 | 12 | param([string]$Url, [switch]$help) 13 | 14 | [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 15 | 16 | function GetHelp() { 17 | 18 | 19 | $HelpText = @" 20 | 21 | DESCRIPTION: 22 | NAME: Get-SPSite 23 | Opens a connection to a Microsoft.SharePoint.SPSite Collection 24 | 25 | PARAMETERS: 26 | -url Url to SharePoint Site Collection 27 | 28 | SYNTAX: 29 | 30 | $SPSite = Get-SPSite -url http://moss 31 | 32 | Opens The SiteCollection. 33 | 34 | Get-SPSite -help 35 | 36 | Displays the help topic for the script 37 | 38 | "@ 39 | $HelpText 40 | 41 | } 42 | 43 | function Get-SPSite([string]$url) { 44 | 45 | New-Object Microsoft.SharePoint.SPSite($url) 46 | } 47 | 48 | if($help) { GetHelp; Continue } 49 | if($url) { Get-SPSite -url $url } -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/powershell.nu_moss2007_script_collection/Get-SPWeb.ps1: -------------------------------------------------------------------------------- 1 | ################################################################################## 2 | # 3 | # 4 | # Script name: Get-SPWeb.ps1 5 | # 6 | # Author: niklas.goude@zipper.se 7 | # Homepage: www.powershell.nu 8 | # Company: www.zipper.se 9 | # 10 | ################################################################################## 11 | 12 | param([string]$Url, [switch]$help) 13 | 14 | [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 15 | 16 | function GetHelp() { 17 | 18 | 19 | $HelpText = @" 20 | 21 | DESCRIPTION: 22 | NAME: Get-SPWeb 23 | Opens a connection a site that holds web contents 24 | 25 | PARAMETERS: 26 | -url Url to SharePoint Site 27 | 28 | SYNTAX: 29 | 30 | $SPWeb = Get-SPWeb -url http://moss 31 | 32 | Opens The SiteCollection. 33 | 34 | Get-SPWeb -help 35 | 36 | Displays the help topic for the script 37 | 38 | "@ 39 | $HelpText 40 | 41 | } 42 | 43 | function Get-SPSite([string]$url) { 44 | 45 | New-Object Microsoft.SharePoint.SPSite($url) 46 | } 47 | 48 | function Get-SPWeb([string]$url) { 49 | 50 | $SPSite = Get-SPSite $url 51 | return $SPSite.OpenWeb() 52 | $SPSite.Dispose() 53 | } 54 | 55 | if($help) { GetHelp; Continue } 56 | if($url) { Get-SPWeb -url $url } -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/powershell.nu_moss2007_script_collection/Readme.txt: -------------------------------------------------------------------------------- 1 | Overview: Useful PowerShell scripts that make use of the MOSS 2007 Assemblies and Object Model 2 | 3 | Environments: Created for MOSS 2007 but most of these should also work in SharePoint Server 2010 Farms 4 | 5 | Resource: http://www.powershell.nu/2009/09/08/moss-2007-script-collection -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/powershell.nu_moss2007_script_collection/Set-SPItem.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/MOSS2007/powershell.nu_moss2007_script_collection/Set-SPItem.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/MOSS2007/powershell.nu_moss2007_script_collection/powershell.nu_moss2007_script_collection.txt: -------------------------------------------------------------------------------- 1 | URL: http://www.powershell.nu/2009/09/08/moss-2007-script-collection -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010ActivateFeatureForAllSiteCollectionsAndSites.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Activate Features Across All Site Collections and Sites (webs) in a Web Application ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script to activate a Feature ID across all Sites in all Site Collections in a Web Application 6 | 7 | Environments: SharePoint Server 2010 / 2013 Farms 8 | 9 | Usage: Edit the following variables to match your environment and run the script: '$SPWebApplication'; '$SPFeatureID' 10 | 11 | Resources: 12 | 13 | http://www.smellslikesharepoint.com/2012/06/24/activate-feature-on-all-sites-across-all-site-collections 14 | https://technet.microsoft.com/en-us/library/ee837418.aspx#bkmk_activ_all 15 | http://www.spsdemo.com/Lists/Features/All%20SharePoint%20Features.aspx 16 | 17 | #> 18 | 19 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" 20 | 21 | ### Start Variables ### 22 | $SPWebApplication = "https://YourWebApp.com" 23 | $SPFeatureID = "00bfea71-7e6d-4186-9ba8-c047ac750105" 24 | ### End Variables ### 25 | 26 | Get-SPWebApplication $SPWebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit ALL | foreach {Enable-SPFeature $SPFeatureID -url $_.URL } -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010AddCertificateToManageTrust.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Add a Certificate File (.cer) to the Farm Trust ## 2 | 3 | ## Overview: Adds a certificate (.cer) to the Farms trust relationship manager (/_admin/ManageTrust.aspx) 4 | 5 | ## Environments: SharePoint Server 2010 / 2013 Farms 6 | 7 | ## Usage: Edit the Variables to match your environment and run the script 8 | 9 | ### Start Variables ### 10 | 11 | $CertPath = "C:\BoxBuild\Certs\WorkflowFarm.cer" 12 | $TrustName = "Workflow Manager Farm" 13 | 14 | ### End Variables ### 15 | 16 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 17 | 18 | $trustCert = Get-PfxCertificate $CertPath 19 | 20 | New-SPTrustedRootAuthority -Name $TrustName -Certificate $trustCert -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010ChangeManagedAccountPassword.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server 2010: PowerShell Script to change Managed Account Passwords ## 2 | ## Resource: http://blog.rafelo.com/2010/04/changing-sharepoint-2010-managed.html ## 3 | $ver = $host | select version 4 | if ($ver.Version.Major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"} 5 | Add-PsSnapin Microsoft.SharePoint.PowerShell 6 | Set-location $home 7 | 8 | $inManagedAcct = Read-Host 'Service Account' 9 | 10 | $managedAcct = Get-SPManagedAccount $inManagedAcct 11 | 12 | $inPass = Read-Host 'Enter Password' -AsSecureString 13 | $inPassConfirm = Read-Host 'Confirm Password' -AsSecureString 14 | 15 | Set-SPManagedAccount -Identity $managedAcct -NewPassword $inPass -ConfirmPassword $inPassConfirm -SetNewPassword -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010CompareFilesAndFolders.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Commands To Compare Files And Folders Between Servers ## 2 | ## Usage: Can be used for comparing 'FEATURES' and other directories 3 | ## Compare-Object PowerShell commandlet can be used for any other files and folders - not just SharePoint 4 | 5 | $Server1 = Dir "\\spcharon1\c$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES" 6 | $Server2 = Dir "\\spleda3\c$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES" 7 | 8 | Compare-Object $Server1 $Server2 9 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010CreateGroups/SP2010CreateGroupsFromCSVTemplate.csv: -------------------------------------------------------------------------------- 1 | Web,GroupName,User,GroupDescription 2 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010CreateSiteCollectionInExistingContentDB.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server 2010: PowerShell Script to provision a new Site Collection ## 2 | 3 | Add-PSSnapin Microsoft.SharePoint.Powershell 4 | $SiteCollectionName = "Welcome to My Publishing Site" 5 | $SiteCollectionURL = "http://www.contoso.com/sps/" 6 | $ContentDatabase = "SP2010_ContentDB_Frontend" 7 | $SiteCollectionTemplate = "BLANKINTERNET#1" 8 | $SiteCollectionLanguage = 1033 9 | $SiteCollectionDescription = "Publishing site" 10 | $OwnerAlias = "DOMAIN\admin" 11 | $OwnerEmail = "admin@contoso.com" 12 | $SecondaryOwnerAlias = "DOMAIN\admin2" 13 | $SecondaryEmail = "admin2@contoso.com" 14 | ## Provisions a new Sharepoint Site Collection 15 | New-SPSite -Name $SiteCollectionName -URL $SiteCollectionURL -ContentDatabase $ContentDatabase -Template $SiteCollectionTemplate -Language $SiteCollectionLanguage -Description $SiteCollectionDescription -OwnerAlias $OwnerAlias -OwnerEmail $OwnerEmail -SecondaryOwnerAlias $SecondaryOwnerAlias -SecondaryEmail $SecondaryEmail -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010CreateUserProfiles/CreatePeople.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010CreateUserProfiles/CreatePeople.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010DeleteAllRecycleBinItems.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Function to Clear All Recycle Bin Items ## 2 | 3 | # Overview: Clear all Recycle Bin Items for a site collection (Both Recycle Bin Stages) 4 | # Environments: MOSS 2007, and SharePoint Server 2010 / 2013 Farms 5 | # Function: Clear-All-RecycleBin 6 | # Parameters: SiteCollectionURL : URL for Site Collection 7 | # Usage Example: Clear-All-RecycleBin "http://myWebApplication/sites/mySiteCollection/" 8 | 9 | function Clear-All-RecycleBin([string]$SiteCollectionURL) 10 | { 11 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null 12 | $site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL) 13 | Write-Host "SiteCollectionURL", $SiteCollectionURL 14 | 15 | $SitecollectionRecycleBin = $site.RecycleBin 16 | Write-Host "SitecollectionRecycleBin Number", $SitecollectionRecycleBin.Count 17 | 18 | for ($x = $SitecollectionRecycleBin.Count ; $x -gt 0 ; $x--) 19 | { 20 | $Item = $SitecollectionRecycleBin.Item($x-1) 21 | $SitecollectionRecycleBin.Delete($Item.ID) 22 | } 23 | Write-Host "SitecollectionRecycleBin Number", $SitecollectionRecycleBin.Count 24 | } 25 | 26 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010DeploySTSADMExtensionsWithPowerShellCmdlets.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server 2010: PowerShell Script To Deploy The SharePoint 2010 STSADM Commands and PowerShell Cmdlets WSP ## 2 | ## Resource: Gary Lapointe SharePoint Automation: http://blog.falchionconsulting.com/index.php/downloads 3 | ## Usage: Can effectively be used to add and install any SharePoint WSP that requires "GACDeployment" 4 | 5 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 6 | 7 | # User-modifiable variables 8 | $SolutionName = "Lapointe.SharePoint2010.Automation.wsp" 9 | $SolutionLocation = "D:\BoxBuild\SharePointSolutions" #Change this path to suit your environment 10 | # Non-modifiable variables 11 | $caWebApp = [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local 12 | $caWebApp.Sites[0].Url 13 | 14 | Add-SPSolution -LiteralPath $SolutionLocation\$SolutionName 15 | Write-Host -ForegroundColor Yellow "Added the solution: $SolutionName" 16 | Install-SPSolution -Identity $SolutionName -GACDeployment 17 | Write-Host -ForegroundColor Yellow "Check your solution status at:" ($caWebApp.Sites[0].Url + "/_admin/Solutions.aspx") -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010DownloadBlobsFromDocLibrary.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010DownloadBlobsFromDocLibrary.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010EnableDeveloperDashboard.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server 2010: PowerShell Script To Toggle The Developer Dashboard On All Web Apps In A Farm ## 2 | ## Overview: Same results as the following command: STSADM -o setproperty -pn developer-dashboard -pv OnDemand 3 | 4 | Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue 5 | 6 | $DevDashboardSettings = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings; 7 | $DevDashboardSettings.DisplayLevel = 'OnDemand'; #Change this value to either: 'OnDemand'; 'On'; 'Off' 8 | $DevDashboardSettings.RequiredPermissions = 'EmptyMask'; 9 | $DevDashboardSettings.TraceEnabled = $true; 10 | $DevDashboardsettings.Update() -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010EnumerateListItems.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010EnumerateListItems.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010EnumerateSiteTemplateID.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server 2010: PowerShell Script To Enumerate Site Template IDs ## 2 | ## Resource of Site Template IDs: http://www.sp2010blog.com/Blog/Lists/Posts/Post.aspx?ID=48 3 | 4 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 5 | $web = Get-SPWeb "http://sp2010devportal.npe.theglobalfund.org/sites/recordscenter" 6 | write-host "Web Template:" $web.WebTemplate " | Web Template ID:" $web.WebTemplateId 7 | $web.Dispose() -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010ExportAllSolutionsFromSolutionStore.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server 2010: PowerShell Script To Export All WSP Solutions From The Farm Solution Store ## 2 | ## Resource: http://allaboutmoss.com/2011/10/16/export-wsp-from-farm-solution-store-using-powershell 3 | 4 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 5 | 6 | foreach($solution in Get-SPSolution) 7 | { 8 | try 9 | { 10 | $filename = $solution.Name; 11 | $solution.SolutionFile.SaveAs("C:\BoxBuild\Solutions\$filename") #Change this path to suit your environment 12 | } 13 | catch 14 | { 15 | Write-Host "-error:$_"-foreground red 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010FlushApplicationBLOBCache.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server 2010: PowerShell Script to flush the BLOB cache for a Web Application ## 2 | ## Resource: http://technet.microsoft.com/en-us/library/gg277249.aspx 3 | 4 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 5 | 6 | $webApp = Get-SPWebApplication "" #Change this URL to match your environment 7 | [Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp) 8 | Write-Host "Flushed the BLOB cache for:" $webApp 9 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010FlushBLOBCache.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To Flush BLOB Cache For Web Applications ## 2 | 3 | # Resource: http://technet.microsoft.com/en-us/library/gg277249(v=office.15).aspx 4 | 5 | # Environments: SharePoint Server 2010 / 2013 Farms 6 | 7 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 8 | 9 | $webApp = Get-SPWebApplication "https://webapp.yourdomain.com" #Change the web application name to match your environment 10 | 11 | [Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp) 12 | 13 | Write-Host "Flushed the BLOB cache for:" $webApp -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010FlushFarmBLOBCache.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server 2010: PowerShell Script to flush the BLOB cache in SharePoint Server 2010 Farms ## 2 | ## Resource: http://blog.isaacblum.com/2010/12/27/flush-cache-sharepoint-2010-powershell 3 | Write-Host -ForegroundColor White " - Enabling SP PowerShell cmdlets..." 4 | If ((Get-PsSnapin |?{$_.Name -eq "Microsoft.SharePoint.PowerShell"})-eq $null) 5 | { 6 | $PSSnapin = Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null 7 | } 8 | $webAppall = Get-SPWebApplication 9 | foreach ($_.URL in $webAppall) { 10 | $webApp = Get-SPWebApplication $_.URL 11 | [Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp) 12 | Write-Host "Flushed the BLOB cache for:" $webApp 13 | } -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010GetAllFeaturesOnFilePath.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: Using PowerShell to list all Feature IDs and Feature Titles on a File System Path ## 2 | 3 | # Specify the directory path/s where your features are that you want to list 4 | 5 | # For SharePoint / MOSS 2007 6 | 7 | #cd "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES" 8 | 9 | # For SharePoint Server 2010 10 | 11 | cd "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES" 12 | 13 | # For SharePoint Server 2013 14 | 15 | #cd "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\FEATURES" 16 | 17 | gci -recurse -filter feature.xml | % { $contents=get-content $_.fullname; $x=[XML]$contents; "{0} {1}" -f $x.Feature.Id, $x.feature.title } 18 | 19 | # To output this to a file 20 | 21 | #gci -recurse -filter feature.xml | % { $contents=get-content $_.fullname; $x=[XML]$contents; "{0} {1}" -f $x.Feature.Id, $x.feature.title } > "C:\BoxBuild\Scripts\PowerShell\Features_On_Disk.txt" -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010GetAllInactiveFeatures.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to List All Inactive Features at Farm, Web Application, Site Collection, Web (sub-site) Scope ## 2 | 3 | <# 4 | 5 | Overview: Script that reports on all inactive SharePoint Features at Farm, Web Application, Site Collection, Web (sub-site) Scope 6 | 7 | Environments: SharePoint Server 2010 / 2013 Farms 8 | 9 | Usage: Edit the following areas to meet your Scope requirements and run the sctipt: '$_.Scope', 'Get-SPFeature' 10 | 11 | Resources: 12 | 13 | http://www.theroks.com/list-all-installed-features-that-are-not-active-with-powershell 14 | 15 | http://sharepoint.stackexchange.com/questions/76245/powershell-command-to-find-active-features-for-site-collection 16 | 17 | #> 18 | 19 | $siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Site" } # Farm, WebApp, Site and Web 20 | if ($siteFeatures -ne $null) 21 | { 22 | foreach ($feature in $siteFeatures) 23 | { 24 | # -Site can be replace by -Farm (without url), -WebApp, -Web 25 | if ((Get-SPFeature -Site "https://yoursitecollection.com" | Where-Object {$_.Id -eq $feature.id}) -eq $null) 26 | { 27 | # Inactive features 28 | Write-Host "Scope: $($feature.Scope) FeatureName: $($feature.DisplayName) FeatureID: $($feature.ID) " -ForeGroundColor Green 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010GetAllListColumns.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To List All Site Columns At List Library Level ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script To List All Site Columns At List Library Level. Provides information on the Field Name, Internal Name, and Column Type 6 | 7 | Environments: SharePoint Server 2010 / 2013 + Farms 8 | 9 | Usage: Edit the following variables to match your environment and run the script: '$SiteURL'; '$ListName' 10 | 11 | Resource: http://www.sharepointdiary.com/2016/04/get-list-fields-in-sharepoint-using-powershell.html 12 | 13 | #> 14 | 15 | Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 16 | 17 | #Configuration Parameters 18 | $SiteURL="https://YourSite.com" 19 | $ListName= "YourListName" 20 | 21 | #Get the List 22 | $List = (Get-SPWeb $SiteURL).Lists.TryGetList($ListName) 23 | 24 | Write-Host "Field Name | Internal Name | Type" 25 | Write-Host "------------------------------------" 26 | 27 | #Loop through each field in the list and get the Field Title, Internal Name and Type 28 | ForEach ($Field in $List.Fields) 29 | { 30 | Write-Host $Field.Title"|"$Field.internalName"|"$Field.Type 31 | } 32 | 33 | 34 | #Read more: http://www.sharepointdiary.com/2016/04/get-list-fields-in-sharepoint-using-powershell.html#ixzz58tBLXmub -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010GetAllSiteTemplatesInFarm.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To List Details On All Site Templates In A Farm ## 2 | ## Environments: SharePoint Server 2010 / 2013 Farms 3 | ## Resource: http://get-spscripts.com/2011/02/finding-site-template-names-and-ids-in.html 4 | 5 | Add-PSSnapin "Microsoft.Sharepoint.PowerShell" -ErrorAction SilentlyContinue 6 | 7 | function Get-SPWebTemplateWithId 8 | { 9 | $templates = Get-SPWebTemplate | Sort-Object "Name" 10 | $templates | ForEach-Object { 11 | $templateValues = @{ 12 | "Title" = $_.Title 13 | "Name" = $_.Name 14 | "ID" = $_.ID 15 | "Custom" = $_.Custom 16 | "LocaleId" = $_.LocaleId 17 | } 18 | New-Object PSObject -Property $templateValues | Select @("Name","Title","LocaleId","Custom","ID") 19 | } 20 | } 21 | 22 | # Examples: 23 | Get-SPWebTemplateWithId | Format-Table 24 | Get-SPWebTemplateWithId | Format-Table | Out-File "C:\BoxBuild\Scripts\PowerShell\SP_Site_Templates.txt" -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010GetAllSitesInWebApplication.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Report on All Site Collections and Sites in a Web Application ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script that uses the 'Get-SPSite' commandlet to retrieve all site collections in a web application, and then uses the 'Get-SPWeb' to list properties for all the Sites and Sub-sites associated with them 6 | 7 | Environments: SharePoint Server 2010 / 2013 Farms 8 | 9 | Usage: Edit the following variables to match your environment and run the script: "$WebApplication"; "$ReportPath" 10 | 11 | Note: To get a full report on all the Properties from the 'Get-SPWeb' commandlet; remove the 'Select' statement from the script 12 | 13 | Resource: http://iedaddy.com/2011/11/sharepoint-information-architecture-diagram-using-powershell-and-visio 14 | 15 | #> 16 | 17 | ### Start Variables ### 18 | $WebApplication = "https://insidewebapp.theglobalfund.org" 19 | $ReportPath = "C:\BoxBuild\Scripts\SPSitesReport.csv" 20 | ### End Variables ### 21 | 22 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 23 | 24 | Get-SPWebApplication $WebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, ID, ParentWebID, IsRootWeb, WebTemplate, AssociatedOwnerGroup, AssociatedMemberGroup, HasUniquePerm, Created, LastItemModifiedDate | Export-CSV $ReportPath -NoTypeInformation -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010GetFarmAndSiteCollectionAdmins.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010GetFarmAndSiteCollectionAdmins.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010GetFarmID.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: Determine Your Farm ID With PowerShell ## 2 | 3 | ## Environments: Works on MOSS 2007 and SharePoint Server 2010 Farms 4 | 5 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 6 | $spFarm=[Microsoft.SharePoint.Administration.SPfarm]::Local 7 | $spFarm.Id 8 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010GetTimerJobHistory.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010GetTimerJobHistory.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010GetWebApplicationUsers.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To Export Web Application User Profiles To A CSV File ## 2 | 3 | # Environments: SharePoint Server 2010 Farms 4 | 5 | # Resource: http://snahta.blogspot.ch/2012/08/powershell-exporting-user-profile.html 6 | 7 | Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 8 | 9 | $siteUrl = "http://sp2010WebAppURL" #Change this to suit your environment 10 | $outputFile = "C:\UserProfiles.csv" #Change this path to suit your environment 11 | 12 | $serviceContext = Get-SPServiceContext -Site $siteUrl 13 | $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext); 14 | $profiles = $profileManager.GetEnumerator() 15 | 16 | Write-Host "Exporting profiles" 17 | 18 | $collection = @() 19 | foreach ($profile in $profiles) { 20 | 21 | $profileData = "" | select "AccountName","FirstName", "LastName","PreferredName","WorkPhone" 22 | $profileData.AccountName = $profile["AccountName"].Value 23 | $profileData.FirstName = $profile["FirstName"].Value 24 | $profileData.LastName = $profile["LastName"].Value 25 | $profileData.PreferredName = $profile["PreferredName"].Value 26 | $profileData.WorkPhone = $profile["WorkPhone"].Value 27 | $collection += $profileData 28 | } 29 | 30 | $collection | Export-Csv $outputFile -NoTypeInformation -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010HideListField.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Function To Hide And Unhide SharePoint List Fields ## 2 | ## Resource: http://www.powershell.nu/2009/01/13/hiding-a-listfield-in-newformeditform-in-sharepoint 3 | ## Usage: Works on both MOSS 2007 and SharePoint Server 2010 Farms 4 | 5 | function Hide-SPField([string]$url, [string]$List, [string]$Field) { 6 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 7 | 8 | $SPSite = New-Object Microsoft.SharePoint.SPSite($url) 9 | $OpenWeb = $SPSite.OpenWeb() 10 | 11 | $OpenList = $OpenWeb.Lists[$List] 12 | 13 | $OpenField = $OpenList.Fields[$Field] 14 | $OpenField.ShowInNewForm = $False #Change this value to '$True' if you want the field to be visible again 15 | $OpenField.ShowInEditForm = $False #Change this value to '$True' if you want the field to be visible again 16 | $OpenField.Update() 17 | 18 | $SPSite.Dispose() 19 | $OpenWeb.Dispose() 20 | } 21 | 22 | #Example: 23 | 24 | #Hide-SPField -url "http://moss/site" -List "My Custom List" -Field "UserField" -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010ListAllPowerShellCommandlets.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell List All SharePoint Server PowerShell Commands (Cmdlets) ## 2 | 3 | # Environments: Works on both SharePoint Server 2010 / 2013 Farms 4 | 5 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 6 | 7 | Get-Command –PSSnapin "Microsoft.SharePoint.PowerShell" | format-table name > C:\SP_PowerShell_Commands.txt 8 | 9 | # Obtaining these with more detail 10 | 11 | Get-Command –PSSnapin "Microsoft.SharePoint.PowerShell" | select name, definition | format-list > C:\SP_PowerShell_Commands_Detailed.txt 12 | 13 | # Obtaining a count of these 14 | 15 | (Get-Command -PSSnapin Microsoft.SharePoint.PowerShell).count 16 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010MoveSites/SP2010MoveSite.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010MoveSites/SP2010MoveSite.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010MoveSites/SharePoint 2010 Move Site PowerShell Script Usage Guide v1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010MoveSites/SharePoint 2010 Move Site PowerShell Script Usage Guide v1.docx -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation.htm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation.htm -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/colorschememapping.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/filelist.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image001.png -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image002.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image002.jpg -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image003.png -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image004.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image004.jpg -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image005.png -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image006.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image006.jpg -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image007.png -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image008.jpg -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image009.png -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image010.png -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image011.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/image011.jpg -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/item0001.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/props002.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/themedata.thmx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/Documentation_files/themedata.thmx -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/RetrieveSharePointListData.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/RetrieveSharePointListData.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/SP2010RetrieveSharePointListData.txt: -------------------------------------------------------------------------------- 1 | URL: http://gallery.technet.microsoft.com/scriptcenter/Retrieve-SharePoint-list-8e7fb421 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RetriveSharePointListData/en-US/RetriveSharePointListData.psd1: -------------------------------------------------------------------------------- 1 | ConvertFrom-StringData @' 2 | # English strings 3 | CannotFindItem = Cannot find a item with specified ID. 4 | CannotFindItemRange = Cannot find items with specified ID range. 5 | CannotDLFromNonDocList = Cannot download any document from a non-document library list. 6 | CannotFindSpeciedItem = Cannot find the specfied item: Placeholder01 7 | SaveFilePrompt = Save Placeholder01 to PlaceHolder02. 8 | '@ -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010RunContentTypeHubTimerJobs.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to run the Content Type Hub related Timer Jobs following Content Type Updates ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script that triggers the following timer jobs 'Content Type Hub'; 'Content Type Subscriber'. This is useful to run following changes made in the Content Type Hub that need to be pushed out 6 | 7 | Usage: Edit the '-WebApplication' parameter to match the web applications you want the 'Content Type Subscriber' timer job to run against in your environment 8 | 9 | Environments: SharePoint Server 2010 / 2013 Farms 10 | 11 | #> 12 | 13 | Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue 14 | 15 | #Run the Content Type Hub timer job (default is to run once daily) 16 | $ctHubTJ = Get-SPTimerJob "MetadataHubTimerJob" 17 | $ctHubTJ.RunNow() 18 | 19 | #Run the Content Type Subscriber timer job for a specific Web Application (default to run every hour) 20 | $ctSubTJ = Get-SPTimerJob "MetadataSubscriberTimerJob" -WebApplication "https://yourwebapp.com" #Change this path to match your web application URL 21 | $ctSubTJ.RunNow() -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010SetLoggingLocationPaths.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Set the Path for Diagnostic Logs (ULS) and Usage and Health Data ## 2 | 3 | ## Environments: SharePoint Server 201 / 2013 Farms 4 | 5 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 6 | 7 | #Configure diagnostic logging path (ULS) 8 | Set-SPDiagnosticConfig -LogLocation "D:\Data\SharePoint\Logs\ULS" 9 | 10 | #Configure usage and health data collection 11 | Set-SPUsageService -UsageLogLocation "D:\Data\SharePoint\Logs\Usage" 12 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010SetSiteCollectionAccessLevels.ps1: -------------------------------------------------------------------------------- 1 | ##SharePoint Server 2010: Set-SPSite Commands to Set Site Collections Access to: Read Only; No Additions; No Access; and Unlock ## 2 | # Note: Also available through Central Admin under 'Central Administration -- Site Collection Quotas and Locks' 3 | 4 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" 5 | 6 | #Make a SharePoint 2010 Site Collection Read Only. Also locks down the Site Actions Menu 7 | 8 | Set-SPSite -Identity "http://myserver/sites/site1" -LockState "ReadOnly" 9 | 10 | #Make a SharePoint 2010 Site Collection 'Capped'. No new content - only some modifications on existing content 11 | 12 | Set-SPSite -Identity "http://myserver/sites/site1" -LockState "NoAdditions" 13 | 14 | #Make a SharePoint 2010 Site Collection Unreachable (Block Access) 15 | 16 | Set-SPSite -Identity "http://myserver/sites/site1" -LockState "NoAccess" 17 | 18 | #Unlock a SharePoint 2010 Site Collection. Reverses any of the above Commands 19 | 20 | Set-SPSite -Identity "http://myserver/sites/site1" -LockState "Unlock" 21 | 22 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010SetSiteTheme.ps1: -------------------------------------------------------------------------------- 1 | ##SharePoint Server 2010: PowerShell Script To Set Your Site Theme Across SharePoint Sites and Sub Sites 2 | #Usage Note: Setting the $NewTheme Variable to 'Default' doesn't appear to restore the 'out of the box theme' 3 | 4 | $SiteUrl = "http://intranet.contoso.com" #Change your Site URL here - Script will also set Theme for all Sub Sites 5 | $NewTheme = "Azure" #Set your Theme here 6 | 7 | # Loading Microsoft.SharePoint.PowerShell 8 | $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'} 9 | if ($snapin -eq $null) { 10 | Write-Host "Loading SharePoint Powershell Snapin" 11 | Add-PSSnapin "Microsoft.SharePoint.Powershell" 12 | } 13 | 14 | # Setting site themes on sites and sub sites 15 | $SPSite = Get-SPSite | Where-Object {$_.Url -eq $SiteUrl} 16 | if($SPSite -ne $null) 17 | { 18 | $themes = [Microsoft.SharePoint.Utilities.ThmxTheme]::GetManagedThemes($SiteUrl); 19 | foreach ($theme in $themes) 20 | { 21 | if ($theme.Name -eq $NewTheme) 22 | { 23 | break; 24 | } 25 | } 26 | foreach ($SPWeb in $SPSite.AllWebs) 27 | { 28 | $theme.ApplyTo($SPWeb, $true); 29 | Write-Host "Set" $NewTheme "at :" $SPWeb.Title "(" $SPWeb.Url ")" 30 | } 31 | } 32 | 33 | Write-Host "Themes uodated at:" $SPSite.Url -foregroundcolor Green -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010ShowListFields.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Show All Fields In A List (Includes Custom and System Fields) ## 2 | ## Resource: http://allaboutmoss.com/2010/05/11/3-ways-to-find-sharepoint-list-fields-internal-name 3 | ## Environments: MOSS 2007 and SharePoint Server 2010 4 | 5 | [system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint") 6 | $site= New-Object Microsoft.SharePoint.SPSite ("http://YourSPSite") #Change this to suit your environment 7 | $web=$site.OpenWeb() 8 | $list=$web.Lists["TestCustomList"] #Change this to your list name 9 | $list.Fields |select title, internalname| more -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010SolutionDeployer/SP2010SolutionDeployer.txt: -------------------------------------------------------------------------------- 1 | URLs: 2 | 3 | http://blogs.msdn.com/b/aaronsaikovski/archive/2010/09/06/sharepoint-2010-solution-deployer-v1-1.aspx 4 | 5 | https://skydrive.live.com/?cid=17444de481aa42ac&id=17444DE481AA42AC!801#cid=17444DE481AA42AC&id=17444DE481AA42AC!537 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010SolutionDeployer/usage.txt: -------------------------------------------------------------------------------- 1 | #Deploy solutions 2 | ./solution.ps1 -solutionname test.wsp -Add $true 3 | ./solution.ps1 -solutionname test.wsp -Remove $true 4 | ./solution.ps1 -solutionname test.wsp -upgrade $true 5 | 6 | 7 | #Deploy & activate features 8 | ./Feature.ps1 -FeatureId Test_Feature1 -SiteUrl http://win-d496ifm67d4 -Add 9 | ./Feature.ps1 -FeatureId Test_Feature1 -SiteUrl http://win-d496ifm67d4 -Remove 10 | ./Feature.ps1 -FeatureId Test_Feature1 -SiteUrl http://win-d496ifm67d4 -Get 11 | 12 | 13 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010TestEmailFunctionality.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To Test SharePoint Send Mail Functionality ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script that uses the Object Model to test sending email using the same 'SPUtility.SendMail' configured in the Incoming/Outgoing Central Admin E-Mail Settings 6 | 7 | Environments: SharePoint Server 2010 / 2013 Farms 8 | 9 | Usage: Edit the variables below and run the script 10 | 11 | #> 12 | 13 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 14 | 15 | ##### Begin Variables ##### 16 | $spsite = "https://devinside.npe.theglobalfund.org" #Provide your SharePoint site details here 17 | $email = "yourname@youremail.com" #Add your recipient email address here 18 | $subject = "SharePoint SendMail Test" #Change your subject here 19 | $body = "Email sent via SharePoint site $spsite" #Change your body text here 20 | ##### End Variables ##### 21 | 22 | $site = New-Object Microsoft.SharePoint.SPSite "$spsite" 23 | $web = $site.OpenWeb() 24 | [Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web,0,0,$email,$subject,$body) 25 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2010/SP2010UpdateUserProfilePhotoStore.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2010/SP2010UpdateUserProfilePhotoStore.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013ActivateFeatureForAllSiteCollectionsAndSites.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Activate Features Across All Site Collections and Sites (webs) in a Web Application ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script to activate a Feature ID across all Sites in all Site Collections in a Web Application 6 | 7 | Environments: SharePoint Server 2010 / 2013 Farms 8 | 9 | Usage: Edit the following variables to match your environment and run the script: '$SPWebApplication'; '$SPFeatureID' 10 | 11 | Resources: 12 | 13 | http://www.smellslikesharepoint.com/2012/06/24/activate-feature-on-all-sites-across-all-site-collections 14 | https://technet.microsoft.com/en-us/library/ee837418.aspx#bkmk_activ_all 15 | http://www.spsdemo.com/Lists/Features/All%20SharePoint%20Features.aspx 16 | 17 | #> 18 | 19 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" 20 | 21 | ### Start Variables ### 22 | $SPWebApplication = "https://YourWebApp.com" 23 | $SPFeatureID = "00bfea71-7e6d-4186-9ba8-c047ac750105" 24 | ### End Variables ### 25 | 26 | Get-SPWebApplication $SPWebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit ALL | foreach {Enable-SPFeature $SPFeatureID -url $_.URL } 27 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013AddAlternateSiteCollectionURLMapping.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Add additional URLs in Zones for Host Named Site Collections (HNSC) ## 2 | 3 | ## Environments: SharePoint Server 2013 + Farms 4 | 5 | ## Resource: https://blogs.msdn.microsoft.com/brian_farnhill/2014/07/07/multiple-zones-for-host-named-site-collections-in-sp2013 6 | 7 | $SiteCollectionURL = "https://external.theglobalfund.org" #Provide your original HNSC URL here 8 | $SiteCollectionAlternateURL = "https://vdc2-external.theglobalfund.org" #Provide the new URL to be mapped to the original HNSC 9 | $SiteCollectionZone = "Internet" #Provide the Zone property for the new URL (Default; Intranet; Internet; Custom; Extranet) 10 | 11 | Add-PSSnapin microsoft.sharepoint.powershell 12 | 13 | Set-SPSiteUrl (Get-SPSite $SiteCollectionURL) -Url $SiteCollectionAlternateURL -Zone $SiteCollectionZone 14 | 15 | Get-SPSiteUrl -Identity $SiteCollectionURL -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013AddCertificateToManageTrust.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Add a Certificate File (.cer) to the Farm Trust ## 2 | 3 | ## Overview: Adds a certificate (.cer) to the Farms trust relationship manager (/_admin/ManageTrust.aspx) 4 | 5 | ## Environments: SharePoint Server 2010 / 2013 Farms 6 | 7 | ## Usage: Edit the Variables to match your environment and run the script 8 | 9 | ### Start Variables ### 10 | 11 | $CertPath = "C:\BoxBuild\Certs\WorkflowFarm.cer" 12 | $TrustName = "Workflow Manager Farm" 13 | 14 | ### End Variables ### 15 | 16 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 17 | 18 | $trustCert = Get-PfxCertificate $CertPath 19 | 20 | New-SPTrustedRootAuthority -Name $TrustName -Certificate $trustCert -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013AddSPShellAdmin.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: Powershell Script To Assign An Account Access To The SPShell Access Role 'SharePoint_Shell_Access' For A Specific Database ## 2 | 3 | <# 4 | 5 | Overview: The PowerShell script below adds a specified user to a specified content database with the SQL Server 'SharePoint_Shell_Access' role. The commandlet also adds the account to the 'WSS_ADMIN_WPG' server role 6 | 7 | Environments: SharePoint Server 2013 Farms 8 | 9 | Usage: Edit the following variables to match your environment and run the script: '$UserAccount'; '$contentDB' 10 | 11 | Resources: http://andersrask.sharepointspace.com/Lists/Posts/Post.aspx?ID=12; http://technet.microsoft.com/en-us/library/ff607596(v=office.15).aspx 12 | 13 | Add-SPShellAdmin [-UserName] 14 | [-AssignmentCollection ] 15 | [-Confirm []] 16 | [-database ] 17 | [-WhatIf []] [] 18 | 19 | #> 20 | 21 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 22 | 23 | $UserAccount = "DOMAIN\YourAccount" #Change this to match your user name 24 | $contentDB = Get-SPDatabase | ?{$_.Name -eq "Your_Database_Name"} #Change your database name here 25 | 26 | Add-SPShellAdmin -UserName $UserAccount -database $contentDB -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013DeleteAllRecycleBinItems.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Function to Clear All Recycle Bin Items ## 2 | 3 | # Overview: Clear all Recycle Bin Items for a site collection (Both Recycle Bin Stages) 4 | # Environments: MOSS 2007, and SharePoint Server 2010 / 2013 Farms 5 | # Function: Clear-All-RecycleBin 6 | # Parameters: SiteCollectionURL : URL for Site Collection 7 | # Usage Example: Clear-All-RecycleBin "http://myWebApplication/sites/mySiteCollection/" 8 | 9 | function Clear-All-RecycleBin([string]$SiteCollectionURL) 10 | { 11 | [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null 12 | $site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL) 13 | Write-Host "SiteCollectionURL", $SiteCollectionURL 14 | 15 | $SitecollectionRecycleBin = $site.RecycleBin 16 | Write-Host "SitecollectionRecycleBin Number", $SitecollectionRecycleBin.Count 17 | 18 | for ($x = $SitecollectionRecycleBin.Count ; $x -gt 0 ; $x--) 19 | { 20 | $Item = $SitecollectionRecycleBin.Item($x-1) 21 | $SitecollectionRecycleBin.Delete($Item.ID) 22 | } 23 | Write-Host "SitecollectionRecycleBin Number", $SitecollectionRecycleBin.Count 24 | } 25 | 26 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013EnableEMailNotificationOnLists.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Enable Email Notifications on Lists via CSOM ## 2 | 3 | <# 4 | 5 | Overview: In some SharePoint Farms the 'E-Mail Notification' option to 'Send e-mail when ownership is assigned?' is not present under 'List Settings --> Advanced settings' 6 | 7 | Note: This option only appears to be available on 'Issue Tracking' lists on the affected Farms 'out of the box' 8 | 9 | Environments: SharePoint Server 2013 Farms 10 | 11 | Usage: Edit the following variables to match your environment and run the script: '$SPSite'; '$SPList'. Change the 'EnableAssignToEmail' value to '$false' if you want to disable this property 12 | 13 | Resource: https://gallery.technet.microsoft.com/office/Enable-email-notifications-390a927c 14 | 15 | #> 16 | 17 | Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue 18 | 19 | $SPSite = "https://YourSharePointSite.com" #Provide your SharePoint site URL here 20 | $SPList = "Task List" #provide your List Name here 21 | 22 | $web = Get-SPWeb "$SPSite" 23 | 24 | $list = $web.Lists.TryGetList("$SPList") 25 | 26 | $list.EnableAssignToEmail = $true #Set this to '$false' if you want to disable this property 27 | 28 | $list.Update() -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013EnumSiteCollectionSizes.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To Report On Sizes Of All Sites And Their Content Databases With OutPut To A CSV File ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script to output a list of all SharePoint Content Databases, along with the Site Collections within them and their sizes 6 | 7 | Usage: Edit the '$FilePath' variable and run the script 8 | 9 | Versions: SharePoint Server 2013 Farms 10 | 11 | Resource: http://www.khamis.net/Blog/Post/327/Output-a-list-of-SharePoint-content-databases,-site-collections-within-them-and-their-size-via-PowerShell 12 | 13 | #> 14 | 15 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 16 | 17 | $FilePath = "C:\BoxBuild\Scripts\SPContentDatabases.csv" #Change this file path to match your environment 18 | 19 | $all="Content Database,Site URL,Size`r`n";Get-SPContentDatabase | %{foreach($site in $_.Sites){$url=$site.url;$size=[System.Math]::Round([int64]$site.Usage.Storage/1MB,2); $output="$($_.Name),$($url),$($size)MB`r`n";$all+=$output}}; $all | out-file $FilePath -force -Encoding default -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013ExportAllSolutionsFromSolutionStore.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server 2013: PowerShell Script To Export All WSP Solutions From The Farm Solution Store ## 2 | ## Resource: http://allaboutmoss.com/2011/10/16/export-wsp-from-farm-solution-store-using-powershell 3 | 4 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 5 | 6 | foreach($solution in Get-SPSolution) 7 | { 8 | try 9 | { 10 | $filename = $solution.Name; 11 | $solution.SolutionFile.SaveAs("C:\BoxBuild\Solutions\$filename") #Change this path to suit your environment 12 | } 13 | catch 14 | { 15 | Write-Host "-error:$_"-foreground red 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013FlushBLOBCache.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To Flush BLOB Cache For Web Applications ## 2 | 3 | # Resource: http://technet.microsoft.com/en-us/library/gg277249(v=office.15).aspx 4 | 5 | # Environments: SharePoint Server 2010 / 2013 Farms 6 | 7 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 8 | 9 | $webApp = Get-SPWebApplication "https://webapp.yourdomain.com" #Change the web application name to match your environment 10 | 11 | [Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp) 12 | 13 | Write-Host "Flushed the BLOB cache for:" $webApp -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013GetAllFeaturesOnFilePath.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: Using PowerShell to list all Feature IDs and Feature Titles on a File System Path ## 2 | 3 | # Specify the directory path/s where your features are that you want to list 4 | 5 | # For SharePoint / MOSS 2007 6 | 7 | #cd "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES" 8 | 9 | # For SharePoint Server 2010 10 | 11 | #cd "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES" 12 | 13 | # For SharePoint Server 2013 14 | 15 | cd "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\FEATURES" 16 | 17 | gci -recurse -filter feature.xml | % { $contents=get-content $_.fullname; $x=[XML]$contents; "{0} {1}" -f $x.Feature.Id, $x.feature.title } 18 | 19 | # To output this to a file 20 | 21 | #gci -recurse -filter feature.xml | % { $contents=get-content $_.fullname; $x=[XML]$contents; "{0} {1}" -f $x.Feature.Id, $x.feature.title } > "C:\BoxBuild\Scripts\PowerShell\Features_On_Disk.txt" -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013GetAllListColumns.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To List All Site Columns At List Library Level ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script To List All Site Columns At List Library Level. Provides information on the Field Name, Internal Name, and Column Type 6 | 7 | Environments: SharePoint Server 2010 / 2013 + Farms 8 | 9 | Usage: Edit the following variables to match your environment and run the script: '$SiteURL'; '$ListName' 10 | 11 | Resource: http://www.sharepointdiary.com/2016/04/get-list-fields-in-sharepoint-using-powershell.html 12 | 13 | #> 14 | 15 | Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 16 | 17 | #Configuration Parameters 18 | $SiteURL="https://YourSite.com" 19 | $ListName= "YourListName" 20 | 21 | #Get the List 22 | $List = (Get-SPWeb $SiteURL).Lists.TryGetList($ListName) 23 | 24 | Write-Host "Field Name | Internal Name | Type" 25 | Write-Host "------------------------------------" 26 | 27 | #Loop through each field in the list and get the Field Title, Internal Name and Type 28 | ForEach ($Field in $List.Fields) 29 | { 30 | Write-Host $Field.Title"|"$Field.internalName"|"$Field.Type 31 | } 32 | 33 | 34 | #Read more: http://www.sharepointdiary.com/2016/04/get-list-fields-in-sharepoint-using-powershell.html#ixzz58tBLXmub -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013GetAllSiteTemplatesInFarm.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To List Details On All Site Templates In A Farm ## 2 | ## Environments: SharePoint Server 2010 / 2013 Farms 3 | ## Resource: http://get-spscripts.com/2011/02/finding-site-template-names-and-ids-in.html 4 | 5 | Add-PSSnapin "Microsoft.Sharepoint.PowerShell" -ErrorAction SilentlyContinue 6 | 7 | function Get-SPWebTemplateWithId 8 | { 9 | $templates = Get-SPWebTemplate | Sort-Object "Name" 10 | $templates | ForEach-Object { 11 | $templateValues = @{ 12 | "Title" = $_.Title 13 | "Name" = $_.Name 14 | "ID" = $_.ID 15 | "Custom" = $_.Custom 16 | "LocaleId" = $_.LocaleId 17 | } 18 | New-Object PSObject -Property $templateValues | Select @("Name","Title","LocaleId","Custom","ID") 19 | } 20 | } 21 | 22 | # Examples: 23 | Get-SPWebTemplateWithId | Format-Table 24 | Get-SPWebTemplateWithId | Format-Table | Out-File "C:\BoxBuild\Scripts\PowerShell\SP_Site_Templates.txt" -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013GetAllSitesInWebApplication.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Report on All Site Collections and Sites in a Web Application ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script that uses the 'Get-SPSite' commandlet to retrieve all site collections in a web application, and then uses the 'Get-SPWeb' to list properties for all the Sites and Sub-sites associated with them 6 | 7 | Environments: SharePoint Server 2010 / 2013 Farms 8 | 9 | Usage: Edit the following variables to match your environment and run the script: "$WebApplication"; "$ReportPath" 10 | 11 | Note: To get a full report on all the Properties from the 'Get-SPWeb' commandlet; remove the 'Select' statement from the script 12 | 13 | Resource: http://iedaddy.com/2011/11/sharepoint-information-architecture-diagram-using-powershell-and-visio 14 | 15 | #> 16 | 17 | ### Start Variables ### 18 | $WebApplication = "https://yourwebapp.yourorganisation.com" 19 | $ReportPath = "C:\BoxBuild\Scripts\SPSitesReport.csv" 20 | ### End Variables ### 21 | 22 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 23 | 24 | Get-SPWebApplication $WebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, ID, ParentWebID, IsRootWeb, WebTemplate, AssociatedOwnerGroup, AssociatedMemberGroup, HasUniquePerm, Created, LastItemModifiedDate | Export-CSV $ReportPath -NoTypeInformation -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013GetEnterpriseSearchServiceStatus.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Query the Status of the Enterprise Search Service Application ## 2 | 3 | ## Environments: SharePoint Server 2013 Farms 4 | 5 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 6 | 7 | $ssa = "Search Service Application" #Change this to match your SSA Name 8 | 9 | Get-SPEnterpriseSearchStatus -SearchApplication $ssa -Detailed -Text -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013GetFarmAndSiteCollectionAdmins.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2013/SP2013GetFarmAndSiteCollectionAdmins.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013GetSPCorrelationIDLogs.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Check ULS logs and Merge the Correlation ID Events into One Log File ## 2 | 3 | ## Environments: SharePoint Server 2013 Farms 4 | ## Resource: http://habaneroconsulting.com/insights/An-Even-Better-Way-to-Get-the-Real-SharePoint-Error#.VG84ATTF98F 5 | 6 | Add-PSSnapIn Microsoft.SharePoint.PowerShell 7 | 8 | $CorrelationID = "d9e7c69c-f2a5-f061-86b8-afda705c908c" #Provide your Correlation ID GUID here 9 | $LogFile = "C:\BoxBuild\SPError.log" #Change this log path to suit your environment 10 | Merge-SPLogFile -Path "$LogFile" -Correlation "$CorrelationID" 11 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013ListAllInstalledProducts.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: List all Installed SharePoint Products on a Machine with PowerShell ## 2 | 3 | #Currently looking for SharePoint Server 2013 '90150000' 4 | $listApps=Get-WmiObject -Class Win32_Product | Where {$_.IdentifyingNumber -like “*90150000-*”} 5 | $listApps | Sort -Property Name | ft -Autosize 6 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013ListAllPowerShellCommandlets.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell List All SharePoint Server PowerShell Commands (Cmdlets) ## 2 | 3 | # Environments: Works on both SharePoint Server 2010 / 2013 Farms 4 | 5 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 6 | 7 | Get-Command –PSSnapin "Microsoft.SharePoint.PowerShell" | format-table name > C:\SP_PowerShell_Commands.txt 8 | 9 | # Obtaining these with more detail 10 | 11 | Get-Command –PSSnapin "Microsoft.SharePoint.PowerShell" | select name, definition | format-list > C:\SP_PowerShell_Commands_Detailed.txt 12 | 13 | # Obtaining a count of these 14 | 15 | (Get-Command -PSSnapin Microsoft.SharePoint.PowerShell).count 16 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013RegisterCertForHighTrustApps.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2013/SP2013RegisterCertForHighTrustApps.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013RunContentTypeHubTimerJobs.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to run the Content Type Hub related Timer Jobs following Content Type Updates ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script that triggers the following timer jobs 'Content Type Hub'; 'Content Type Subscriber'. This is useful to run following changes made in the Content Type Hub that need to be pushed out 6 | 7 | Usage: Edit the '-WebApplication' parameter to match the web applications you want the 'Content Type Subscriber' timer job to run against in your environment 8 | 9 | Environments: SharePoint Server 2010 / 2013 Farms 10 | 11 | #> 12 | 13 | Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue 14 | 15 | #Run the Content Type Hub timer job (default is to run once daily) 16 | $ctHubTJ = Get-SPTimerJob "MetadataHubTimerJob" 17 | $ctHubTJ.RunNow() 18 | 19 | #Run the Content Type Subscriber timer job for a specific Web Application (default to run every hour) 20 | $ctSubTJ = Get-SPTimerJob "MetadataSubscriberTimerJob" -WebApplication "https://yourwebapp.com" #Change this path to match your web application URL 21 | $ctSubTJ.RunNow() -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013SetContentTypeHubURL.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To Update The Content Type Hub URL For The Managed Metadata Service ## 2 | 3 | ## Environments: SharePoint Server 2010 / 2013 Farms 4 | 5 | ## Resource: http://www.sharepointanalysthq.com/2010/11/how-to-change-the-content-type-hub-url 6 | 7 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 8 | 9 | $ServiceApplicationName = "Managed Metadata Service" #Change this to match your environment 10 | $ContentTypeHub = "https://contenttypehub.yourdomain.com" #Change this to the path of your Content Type Hub 11 | 12 | Set-SPMetadataServiceApplication -Identity $ServiceApplicationName -HubURI $ContentTypeHub -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013SetLoggingLocationPaths.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script to Set the Path for Diagnostic Logs (ULS) and Usage and Health Data ## 2 | 3 | ## Environments: SharePoint Server 201 / 2013 Farms 4 | 5 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 6 | 7 | #Configure diagnostic logging path (ULS) 8 | Set-SPDiagnosticConfig -LogLocation "D:\Data\SharePoint\Logs\ULS" 9 | 10 | #Configure usage and health data collection 11 | Set-SPUsageService -UsageLogLocation "D:\Data\SharePoint\Logs\Usage" 12 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013SetMaximumFileSizePerExtension.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To Set The Maximum File Size Limit Per File Extension At Web Application Level ## 2 | 3 | <# 4 | Environments: SharePoint Server 2013 Farms 5 | 6 | Resources: 7 | 8 | http://sharepointrelated.com/2012/07/30/maximum-file-size-per-extension-in-sharepoint-2013 9 | http://blogs.technet.com/b/sammykailini/archive/2013/11/06/how-to-increase-the-maximum-upload-size-in-sharepoint-2013.aspx 10 | 11 | #> 12 | 13 | ##### Begin Variables ##### 14 | $WebAppURL = "" 15 | $FileExtension = "" #Just provide the file extension here e.g wmv 16 | $FileSize = "" #Provide the maximum file size value in MB 17 | ##### End Variables ##### 18 | 19 | # Check what is currently configured for your web application 20 | 21 | $WebApp = Get-SPWebApplication "$WebAppURL" 22 | $WebApp.MaximumFileSizePerExtension 23 | 24 | # Now add your maximum file extension type and maximum size value 25 | 26 | $WebApp = Get-SPWebApplication "" 27 | $WebApp.MaximumFileSizePerExtension.Add("$FileExtension","$FileSize") 28 | $WebApp.Update() -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013TestEmailFunctionality.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Server: PowerShell Script To Test SharePoint Send Mail Functionality ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Script that uses the Object Model to test sending email using the same 'SPUtility.SendMail' configured in the Incoming/Outgoing Central Admin E-Mail Settings 6 | 7 | Environments: SharePoint Server 2010 / 2013 Farms 8 | 9 | Usage: Edit the variables below and run the script 10 | 11 | #> 12 | 13 | Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue 14 | 15 | ##### Begin Variables ##### 16 | $spsite = "https://devinside.npe.theglobalfund.org" #Provide your SharePoint site details here 17 | $email = "yourname@youremail.com" #Add your recipient email address here 18 | $subject = "SharePoint SendMail Test" #Change your subject here 19 | $body = "Email sent via SharePoint site $spsite" #Change your body text here 20 | ##### End Variables ##### 21 | 22 | $site = New-Object Microsoft.SharePoint.SPSite "$spsite" 23 | $web = $site.OpenWeb() 24 | [Microsoft.SharePoint.Utilities.SPUtility]::SendEmail($web,0,0,$email,$subject,$body) 25 | -------------------------------------------------------------------------------- /PowerShell/Working/SharePoint/SharePoint2013/SP2013UpdateUserProfilePhotoStore.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/SharePoint/SharePoint2013/SP2013UpdateUserProfilePhotoStore.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/Snippets/ForEachFromCSVImport.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script showing how to use a 'ForEach' loop for importing data from a CSV File ## 2 | 3 | $InputFilePath = "C:\BoxBuild\Scripts\SPSitesReport.csv" #Change this to match your environment 4 | 5 | $CsvFile = Import-Csv $InputFilePath 6 | 7 | ForEach ($line in $CsvFile) 8 | 9 | { 10 | 11 | #Add your command syntax here like the example below 12 | 13 | Write-Host $line.URL #In this example we display / write the value for a column called 'URL' in the CSV input file 14 | 15 | } -------------------------------------------------------------------------------- /PowerShell/Working/Snippets/GetDotNetFrameworkVersions.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Function to return the number of .NET Framework Versions Installed on a Client ## 2 | 3 | function Get-DotNETFrameworkVersions() 4 | { 5 | Write-Host "" 6 | Write-Host "Version Table on MSDN: https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx" 7 | Write-Host "Release 379893 is .NET Framework 4.5.2" -ForegroundColor "Yellow" 8 | Write-Host "" 9 | Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | 10 | Get-ItemProperty -name Version,Release -EA 0 | 11 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | 12 | Select PSChildName, Version, Release 13 | } 14 | 15 | Get-DotNETFrameworkVersions -------------------------------------------------------------------------------- /PowerShell/Working/Snippets/GetInternetExplorerTrustedSites.ps1: -------------------------------------------------------------------------------- 1 | ## Internet Explorer: PowerShell Script to List Trusted Sites in IE Browser ## 2 | 3 | ## Overview: Script Gets all the Trusted Sites stored in Internet Explorer (IE) under 'Internet Options - Security - Trusted Sites' 4 | 5 | $_List1 = @() 6 | $_List2 = @() 7 | $_List3 = @() 8 | 9 | $_List1 = $(Get-item 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMapKey' -ErrorAction SilentlyContinue).property 10 | 11 | $_List2 = $(Get-item 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMapKey' -ErrorAction SilentlyContinue).property | Out-GridView 12 | 13 | $_List3 = $_List1 + $_List2 14 | $_List3 | Out-GridView -------------------------------------------------------------------------------- /PowerShell/Working/Snippets/SearchForPhraseInFiles.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Useful function to Search a File Path Location for Phrase Key Words ## 2 | 3 | ## Overview: PowerShell function that parses through a file path location to locate any files that match a search phrase. The results output to the Grid View window 4 | 5 | ## Usage: Run the function with the '-SearchPhrase' and '-Path' parameters (optional - otherwise the location set under '$Path' is used) 6 | 7 | ## Resource: http://www.asifsaif.com/2015/08/quickly-finding-scripts.html 8 | 9 | #requires -Version 3 10 | function Find-Script 11 | { 12 | param 13 | ( 14 | [Parameter(Mandatory = $true)] 15 | $SearchPhrase, 16 | $Path = [Environment]::GetFolderPath('MyDocuments') 17 | ) 18 | 19 | Get-ChildItem -Path $Path -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue | 20 | Select-String -Pattern $SearchPhrase -List | 21 | Select-Object -Property Path, Line | 22 | Out-GridView -Title "All Scripts containing $SearchPhrase" -PassThru | 23 | ForEach-Object -Process { 24 | ise $_.Path 25 | } 26 | } 27 | 28 | #Example 29 | #Find-Script -SearchPhrase "Content Type Hub" -Path "C:\BoxBuild\GitHub\Scripts\PowerShell\Working" -------------------------------------------------------------------------------- /PowerShell/Working/TerminalService/GetActiveTerminalServiceRDPSessions.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/TerminalService/GetActiveTerminalServiceRDPSessions.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/certificates/GetInstalledCertificates.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script to list Certificate Details stored in a Local Machine / Currecnt User Certificate Store ## 2 | 3 | Set-Location Cert:\LocalMachine\My #Set the path to the 'Local Computer' Personal certificate store 4 | #Set-Location Cert:\CurrentUser\My #Set the path to the 'Current User' Personal Certfiicate store 5 | 6 | Get-ChildItem | Format-Table Subject, FriendlyName, Thumbprint, NotBefore, NotAfter -------------------------------------------------------------------------------- /PowerShell/Working/diskspace/GetClusterSharedVolumesCSVSpace.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell Script to Display Disk Information for Cluster Shared Volumes (CSV) ## 2 | 3 | Import-Module FailoverClusters 4 | 5 | $objs = @() 6 | 7 | $csvs = Get-ClusterSharedVolume 8 | foreach ( $csv in $csvs ) 9 | { 10 | $csvinfos = $csv | select -Property Name -ExpandProperty SharedVolumeInfo 11 | foreach ( $csvinfo in $csvinfos ) 12 | { 13 | $obj = New-Object PSObject -Property @{ 14 | Name = $csv.Name 15 | Path = $csvinfo.FriendlyVolumeName 16 | Size = $csvinfo.Partition.Size 17 | FreeSpace = $csvinfo.Partition.FreeSpace 18 | UsedSpace = $csvinfo.Partition.UsedSpace 19 | PercentFree = $csvinfo.Partition.PercentFree 20 | } 21 | $objs += $obj 22 | } 23 | } 24 | 25 | $objs | ft -auto Name ,Path, @{ Label = "Size(GB)" ; Expression = { "{0:N2}" -f ($_.Size /1024/ 1024/1024 ) } },@{ Label = "FreeSpace(GB)" ; Expression = { "{0:N2}" -f ($_.FreeSpace/ 1024/1024 /1024) } } ,@{ Label = "UsedSpace(GB)" ; Expression = { "{0:N2}" -f ($_.UsedSpace/1024 /1024/ 1024) } }, @{ Label = "PercentFree" ; Expression = { "{0:N2}" -f ( $_.PercentFree) } } 26 | -------------------------------------------------------------------------------- /PowerShell/Working/diskspace/diskspacereport/list.txt: -------------------------------------------------------------------------------- 1 | SPCHARON1 2 | SPLEDA3 3 | SPLEDA4 -------------------------------------------------------------------------------- /PowerShell/Working/diskspace/diskspacereport/start.bat: -------------------------------------------------------------------------------- 1 | powershell.exe -command "& 'C:\My Scripts\diskspace.ps1' 'C:\My Scripts\list.txt'" 2 | -------------------------------------------------------------------------------- /PowerShell/Working/email/SMTPEmailTest.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Simple SMTP Email Check Script ## 2 | ## Requires PowerShell 2.0 and higher for the Send-MailMessage Commandlet ## 3 | 4 | ############# Start Variables ################ 5 | $SMTPServerName = "smtp.servername.com" 6 | $MailServerPort = "25" 7 | $SenderServerName = "ServerName" 8 | $MailFrom = "SMTPTest@YourDomain.com" 9 | $MailTo = "YourUser@YourDomain.com" 10 | $Subject = "Subject:Telnet SMTP Mail Test" 11 | $MailBody = "This is a Telnet SMTP Mail Test." 12 | ############# End Variables ################ 13 | 14 | Send-MailMessage –From $MailFrom –To $MailTo –Subject $Subject –Body $MailBody -SmtpServer $SMTPServerName -------------------------------------------------------------------------------- /PowerShell/Working/email/SendEmailWithAttachment.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script to send an Email with an Attachment, along with HTML Content ## 2 | 3 | ## Usage: Edit the variables to match your requirements, and comment out any parameters you don't want to use 4 | 5 | ### Start Variables ### 6 | $fromaddress = "YourFromAddress@YourDomain.com" 7 | $toaddress = "YourToAddress@YourDomain.com" 8 | $bccaddress = "YourBCCAddress@YourDomain.com" 9 | $CCaddress = "YourCCAddress@YourDomain.com" 10 | $Subject = "Your Subject Details" 11 | $body = get-content .\content.htm #Include a path to your HTML body file or provide your $body content within "" 12 | $attachment = "C:\BoxBuild\Emails\YourFile.csv" #Include the path to your file you want to attach 13 | $smtpserver = "Email.YourDomain.com" 14 | ### End Variables ### 15 | 16 | ## Send the email 17 | $message = new-object System.Net.Mail.MailMessage 18 | $message.From = $fromaddress 19 | $message.To.Add($toaddress) 20 | $message.CC.Add($CCaddress) 21 | $message.Bcc.Add($bccaddress) 22 | $message.IsBodyHtml = $True 23 | $message.Subject = $Subject 24 | $attach = new-object Net.Mail.Attachment($attachment) 25 | $message.Attachments.Add($attach) 26 | $message.body = $body 27 | $smtp = new-object Net.Mail.SmtpClient($smtpserver) 28 | $smtp.Send($message) -------------------------------------------------------------------------------- /PowerShell/Working/email/SendEmailWithHTML.ps1: -------------------------------------------------------------------------------- 1 | ##PowerShell: Script To Send an Email with HTML Formatting In The Message Body 2 | 3 | $getdate = get-date -Format D 4 | 5 | $smtpServer = "smtp.server.here" #Add your SMTP Server details here 6 | $smtpFrom = "fromemail@emailhere.com" #Change the from address here 7 | $smtpTo = "toemail@emailhere.com" #Change the to address here. Add additional recipients with a ',' after each other 8 | $messageSubject = "Subject details here" #Change the subject here 9 | 10 | $message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto 11 | $message.Subject = $messageSubject 12 | $message.IsBodyHTML = $true 13 | 14 | $message.Body = "Meeting Time: $getdate between 11:00 to 12:00 AM

Meeting Venue:The House On the Hill

" 15 | 16 | $smtp = New-Object Net.Mail.SmtpClient($smtpServer) 17 | $smtp.Send($message) -------------------------------------------------------------------------------- /PowerShell/Working/files/CheckForFilesWithEmailAlert.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell Script to Check for File/s and Sends an Email if these don't exist ## 2 | ## Useful for checking for backup files etc. 3 | 4 | function SendMail($filename) 5 | { 6 | $emailFrom = "Email@myco.com" 7 | $emailTo = "EmailGroup@myco.com" 8 | $subject = "Missing file - $filename does not exist" 9 | $body = "Missing file - $filename does not exist" 10 | $smtpServer = "mail1" 11 | $smtp = new-object Net.Mail.SmtpClient($smtpServer) 12 | $smtp.Send($emailFrom, $emailTo, $subject, $body) 13 | } 14 | 15 | function Check4File($filename) 16 | { 17 | $bck = get-childitem $filename | where {((get-date) - $_.LastWriteTime).minutes -lt 9} 18 | if (!$bck) { 19 | SendMail($filename) 20 | } 21 | } 22 | 23 | ## Usage Examples ## 24 | 25 | Check4File "C:\Temp\MyFile.txt" 26 | #Check4File "C:\Temp\*.txt" 27 | #Check4File "C:\Temp\MySQLBackup.sqb" -------------------------------------------------------------------------------- /PowerShell/Working/files/DeleteFilesAfterNumberOfDays.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script To Delete File Types from Folders Older Than a Specified Number of Days ## 2 | ## Usage: Goes through specified folders and sub-folders deleting all specified file types older than a specified date 3 | #--- Start define parameters ---# 4 | #--- get current date ---# 5 | $Now = Get-Date 6 | #--- define amount of days ---# 7 | $Days = "7" 8 | #--- define folders where the files are located (add additional ones with commas like: ,"C:\ztemp\Logs1" ---# 9 | $TargetFolders = "C:\ztemp\Logs","C:\ztemp\Logs1" 10 | #--- define extensions (add additional ones with commas like: ,"*.csv" ---# 11 | $Extensions = "*.log","*.csv" 12 | #--- define LastWriteTime parameter based on $Days ---# 13 | $LastWrite = $Now.AddDays(-$Days) 14 | #--- End define parameters ---# 15 | 16 | #--- get files based on lastwrite filter and specified folder ---# 17 | $Files = Get-Childitem $TargetFolders -Include $Extensions -Recurse | Where {$_.LastWriteTime -le "$LastWrite"} 18 | 19 | foreach ($File in $Files) 20 | { 21 | if ($File -ne $NULL) 22 | { 23 | write-host "Deleting file $File" -ForegroundColor "White" 24 | Remove-Item $File.FullName | out-null 25 | } 26 | else 27 | { 28 | Write-Host "No recent files to delete!" -foregroundcolor "Green" 29 | } 30 | } -------------------------------------------------------------------------------- /PowerShell/Working/files/DeleteFilesAfterNumberOfDaysFunction.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Function to Delete Files In a Folder older than a Specified Number of Days ## 2 | 3 | $days=-7 #Change this to reflect the number of days files you wish to retain 4 | (Get-Variable Path).Options="ReadOnly" 5 | $Path="C:\inetpub\logs\LogFiles\W3SVC1" #Change this path to suit your environment 6 | Write-Host "Removing IIS-logs keeping last" $days "days" 7 | CleanTempLogfiles($Path) 8 | 9 | function CleanTempLogfiles() 10 | { 11 | param ($FilePath) 12 | Set-Location $FilePath 13 | Foreach ($File in Get-ChildItem -Path $FilePath) 14 | { 15 | if (!$File.PSIsContainerCopy) 16 | { 17 | if ($File.LastWriteTime -lt ($(Get-Date).Adddays($days))) 18 | 19 | { 20 | remove-item -path $File -force 21 | Write-Host "Removed logfile: " $File 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /PowerShell/Working/files/ListFileSizesInDirectoryFunction.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Function to Convert File Length Properties into a more Readable Human Format ## 2 | 3 | $properties = @( 4 | 'Name' 5 | 'Directory' 6 | @{ 7 | Label = 'Size' 8 | Expression = { 9 | if ($_.Length -ge 1GB) 10 | { 11 | '{0:F2} GB' -f ($_.Length / 1GB) 12 | } 13 | elseif ($_.Length -ge 1MB) 14 | { 15 | '{0:F2} MB' -f ($_.Length / 1MB) 16 | } 17 | elseif ($_.Length -ge 1KB) 18 | { 19 | '{0:F2} KB' -f ($_.Length / 1KB) 20 | } 21 | else 22 | { 23 | '{0} bytes' -f $_.Length 24 | } 25 | } 26 | } 27 | ) 28 | 29 | ##Usage Example: 30 | Get-ChildItem -Path '\\SPTALOS13\i$\MSSQL11.SQL13\MSSQL\DATA\' -Recurse -Include *.MDF -ErrorAction SilentlyContinue | 31 | Sort-Object -Property Length -Descending | 32 | Format-Table -Property $properties #| 33 | #Out-File 'C:\ztemp\files.txt' -------------------------------------------------------------------------------- /PowerShell/Working/files/MoveBackupFiles.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script To Move File Types From One Location To Another ## 2 | ## Usage: Powershell move backup files script – useful for SQL backups or any other files that need to be moved 3 | 4 | $file = "F:\temp\Job_logs" ## This will be your source backup folder 5 | $archive = "F:\temp\archive\" ## This will be your destination folder 6 | 7 | foreach ($file in gci $file -include *.bak -recurse) ## Change the file type here to suit other backup file types 8 | { 9 | Move-Item -path $file.FullName -destination $archive ## Move the files to the archive folder 10 | } 11 | -------------------------------------------------------------------------------- /PowerShell/Working/files/ReplaceStringInFilesInDirectory.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell Script to Search For And Replace Strings In Specific Files In A Directory ## 2 | 3 | ### Start Variables ### 4 | $FilePath = "C:\BoxBuild\Scripts\Monitors" 5 | $FileType = "ps1" #Replace this with a '*' for all files if you don't want a file type filter 6 | $OriginalString = "email.yourorg.com" 7 | $NewString = "appmail.yourorg.com" 8 | 9 | ### End Variables ### 10 | 11 | cd $FilePath 12 | 13 | $configFiles=get-childitem . *.$FileType -recurse 14 | foreach ($file in $configFiles) 15 | { 16 | (Get-Content $file.PSPath) | 17 | Foreach-Object {$_ -replace $OriginalString, $NewString} | 18 | Set-Content $file.PSPath 19 | } -------------------------------------------------------------------------------- /PowerShell/Working/hotfixes/CompareHotFixes.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Useful Query To Compare Hot Fixes Between 2 Machines ## 2 | 3 | $node1 = Get-HotFix -ComputerName "MachineName1" 4 | $node2 = Get-HotFix -ComputerName "MachineName2" 5 | Compare-Object -ReferenceObject $node1 -DifferenceObject $node2 -Property HotFixID -------------------------------------------------------------------------------- /PowerShell/Working/iis/IIS_Get_All_App_Pool_Credentials.ps1: -------------------------------------------------------------------------------- 1 | ## IIS Server: Get Application Pool User Names (Identity) and Passwords Using Web Server (IIS) Administration Cmdlets ## 2 | 3 | $appPools = Get-WebConfiguration -Filter '/system.applicationHost/applicationPools/add' 4 | 5 | foreach($appPool in $appPools) 6 | { 7 | if($appPool.ProcessModel.identityType -eq "SpecificUser") 8 | { 9 | Write-Host $appPool.Name -ForegroundColor Green -NoNewline 10 | Write-Host " -"$appPool.ProcessModel.UserName"="$appPool.ProcessModel.Password 11 | } 12 | } -------------------------------------------------------------------------------- /PowerShell/Working/iis/IIS_Get_App_Pool_Credentials.ps1: -------------------------------------------------------------------------------- 1 | ## IIS Server: Get Application Pool User Name (Identity) and Password Using appcmd ## 2 | 3 | $AppPoolName = "YourAppPoolName" #Provide your application pool name here 4 | 5 | cd "C:\Windows\System32\inetsrv" 6 | 7 | ./appcmd.exe list apppool "$AppPoolName" /text:* -------------------------------------------------------------------------------- /PowerShell/Working/iis/IIS_Get_Web_Sites.ps1: -------------------------------------------------------------------------------- 1 | ## IIS Server: PowerShell Script to List All Web Sites within IIS, and Exports these to a CSV file ## 2 | 3 | ## Overview: Uses the 'WebAdministration' PowerShell module to report on IIS web sites within an IIS server 4 | 5 | ## Usage: Modify the '-Path' variable to suit your environment and run the script 6 | 7 | ## Resource: http://technet.microsoft.com/en-us/library/ee790599.aspx 8 | 9 | Import-Module WebAdministration 10 | 11 | get-website | select name,id,state,physicalpath, 12 | @{n="Bindings"; e= { ($_.bindings | select -expa collection) -join ';' }} , 13 | @{n="LogFile";e={ $_.logfile | select -expa directory}}, 14 | @{n="attributes"; e={($_.attributes | % { $_.name + "=" + $_.value }) -join ';' }} | 15 | Export-Csv -NoTypeInformation -Path "C:\IIS_Web_Sites.csv" #Change this path to suit your environment -------------------------------------------------------------------------------- /PowerShell/Working/iis/IIS_Recycle_App_Pool_Remotely.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Script to Stop / Start / Recycle an IIS Application Pool Remotely ## 2 | 3 | $pc = "MachineName" ##Provide your machine name here 4 | 5 | ## 1. List the app pools, note the __RELPATH of the one you want to target: 6 | Get-WMIObject IISApplicationPool -Computer $pc -Namespace root\MicrosoftIISv2 -Authentication PacketPrivacy 7 | 8 | ## 2. Target a specific Application Pool: 9 | $Name = "W3SVC/APPPOOLS/AppPoolName" ##This is the __RELPATH property for the IIsApplicationPool.Name determined from the query above 10 | $Path = "IISApplicationPool.Name='$Name'" ##This is the __RELPATH 11 | 12 | ## 3. Invoke the command against the remote Aplication Pool. The Invoke-WMIMethod accepts the following commands: Stop / Start / Recycle 13 | Invoke-WMIMethod Recycle -Path $Path -Computer $pc -Namespace root\MicrosoftIISv2 -Authentication PacketPrivacy -------------------------------------------------------------------------------- /PowerShell/Working/network/MonitorPorts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/network/MonitorPorts.pdf -------------------------------------------------------------------------------- /PowerShell/Working/network/MonitorPorts.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/network/MonitorPorts.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/o365/AssignMSOnlineRoleDelegationToUsers.ps1: -------------------------------------------------------------------------------- 1 | ## Office 365: PowerShell Commands to Get / Add / Remove Members from Delegated Roles ## 2 | 3 | Connect-MsolService 4 | 5 | ##Review the available roles for delegation (Company Administrator is the same as 'Global Administrator') 6 | 7 | Get-MsolRole | ft –AutoSize 8 | 9 | ##Get users already delegated access to a particular role (change the '-RoleName' parameter if required) 10 | 11 | Get-MsolRoleMember -RoleObjectId (Get-MsolRole -RoleName "SharePoint Service Administrator").ObjectId | ft –AutoSize 12 | 13 | ##Add a user as a member to a particular role (change the '-RoleMemberEmailAddress' parameter, and '-RoleName' if required) 14 | 15 | Add-MsolRoleMember -RoleName "SharePoint Service Administrator" -RoleMemberEmailAddress "neal.hicks@summit7systems.com" 16 | 17 | ##Remove a user from the members of a particular role (change the '-RoleMemberEmailAddress' parameter, and '-RoleName' if required) 18 | 19 | Remove-MsolRoleMember -RoleName "SharePoint Service Administrator" -RoleMemberEmailAddress "neal.hicks@summit7systems.com" -------------------------------------------------------------------------------- /PowerShell/Working/o365/ConnectToExchangeOnline.ps1: -------------------------------------------------------------------------------- 1 | ## MSOnline: PowerShell Script to Connect to Exchange Online PowerShell Module (o365) ## 2 | 3 | Import-PSSession $(New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Authentication Basic -AllowRedirection -Credential $(Get-Credential)) 4 | 5 | ##Useful commandlets ## 6 | 7 | #Get-UserPhoto "UserName" 8 | #Remove-UserPhoto "UserName" 9 | #Get-DistributionGroup -Identity 'GroupName*' -------------------------------------------------------------------------------- /PowerShell/Working/o365/ConnectToMSOnlineAndExchangeOnlineFunction.ps1: -------------------------------------------------------------------------------- 1 | ## MSOnline: PowerShell Function to Connect to MS Online and Exchange Online PowerShell Modules (o365) ## 2 | 3 | Function Connect-O365 { 4 | 5 | Param ( 6 | [Parameter(Mandatory=$true)] 7 | $User 8 | ) 9 | 10 | $Cred = Get-Credential -Credential $User 11 | 12 | $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection 13 | 14 | Import-Module (Import-PSSession $Session -AllowClobber) -Global 15 | 16 | Connect-MSOLService -Credential $Cred 17 | 18 | } 19 | 20 | ## Call the function 21 | Connect-O365 -------------------------------------------------------------------------------- /PowerShell/Working/o365/DirSyncStartOnlineCoexistenceSync.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Commandlet to manually start Active Directory Synchronization (Dir Sync) with Office 365 ## 2 | 3 | ## The 'Add-PSSnapin' method was replaced on later DirSync clients with the 'Import-Module' command below 4 | 5 | #Add-PSSnapin "Coexistence-Configuration" -ErrorAction SilentlyContinue 6 | 7 | Import-Module Dirsync 8 | 9 | Start-OnlineCoexistenceSync -------------------------------------------------------------------------------- /PowerShell/Working/o365/ExchangeOnline/ExchangeOnlineGetMailBoxPermissions.ps1: -------------------------------------------------------------------------------- 1 | ## Exchange Online: PowerShell Script to List all Users who have 'Full Access' and 'Send As' Rights on other Users Mail Boxes (o365) ## 2 | 3 | ## Resource: http://www.ehloworld.com/277 4 | 5 | $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic –AllowRedirection 6 | Import-PSSession $Session 7 | 8 | ##Find users who have Full Access to the mailbox of others 9 | Get-Mailbox -ResultSize Unlimited | Get-MailboxPermission | Where-Object {($_.AccessRights -match "FullAccess") -and -not ($_.User -like "NT AUTHORITY\SELF")} | Format-Table Identity, User 10 | 11 | ##Find users who have Send-As Access to the mailbox of others 12 | Get-Mailbox -Resultsize Unlimited | Get-MailboxPermission | Where-Object {($_.ExtendedRights -like "*send-as*") -and -not ($_.User -like "nt authority\self")} | Format-Table Identity, User -auto -------------------------------------------------------------------------------- /PowerShell/Working/o365/ExchangeOnline/ExchangeOnlineGetUserDetails.ps1: -------------------------------------------------------------------------------- 1 | ## Exchange Online: PowerShell Script to Get User Account Details ## 2 | 3 | $ExchangeCredential= Get-Credential 4 | 5 | $Session=New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic –AllowRedirection 6 | 7 | Import-PSSession $Session 8 | 9 | #Getting a Full List of the User details 10 | Get-User -Identity "UserName" | fl #Provide your user name for the '-Identity' parameter 11 | 12 | #Getting a Filtered List of the User details 13 | #Get-User -Identity "UserName" | ft identity, whenCreated, whenChanged #Provide your user name for the '-Identity' parameter, along with any additional properties 14 | 15 | #Remove-PSSession $Session -------------------------------------------------------------------------------- /PowerShell/Working/o365/ExchangeOnline/ExchangeOnlineSetMailBoxAuditing.ps1: -------------------------------------------------------------------------------- 1 | ## Exchange Online: PowerShell Script to Enable or Disable Mail Box Auditing in Exchange Online (o365) ## 2 | 3 | ## Resource: https://www.ronnipedersen.com/2017/07/29/automate-mailbox-auditing-office-365 4 | 5 | ## Connect to Exchange Online 6 | Import-PSSession $(New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Authentication Basic -AllowRedirection -Credential $(Get-Credential)) 7 | 8 | ## Get the current state of audit logging 9 | Get-Mailbox -Filter {RecipientTypeDetails -eq "UserMailbox"} -ResultSize Unlimited | Select Name,AuditEnabled,AuditLogAgeLimit 10 | 11 | ## Enable / Disable mailbox audit logging 12 | Get-Mailbox -Filter {RecipientTypeDetails -eq "UserMailbox"} -ResultSize Unlimited | Set-Mailbox -AuditEnabled $True #Change this value to $False if you want to disable auditing 13 | 14 | ## Set the age limit for mailbox audit logging 15 | Get-Mailbox -Filter {RecipientTypeDetails -eq "UserMailbox"} -ResultSize Unlimited | Set-Mailbox -AuditLogAgeLimit 365 #Change this value to the number of days you want to retain the audit logs 16 | 17 | ## Verify the current state of audit logging 18 | Get-Mailbox -Filter {RecipientTypeDetails -eq "UserMailbox"} -ResultSize Unlimited | Select Name,AuditEnabled,AuditLogAgeLimit 19 | -------------------------------------------------------------------------------- /PowerShell/Working/o365/ExchangeOnline/ExchangeOnlineSetUserPhoto.ps1: -------------------------------------------------------------------------------- 1 | ## Exchange Online: PowerShell Script to Add / Update a User Photo in Exchange Online (o365) ## 2 | 3 | ## Resource: https://blogs.technet.microsoft.com/dpickett/2016/09/09/o365-user-photos-not-updating 4 | 5 | ### Start Variables ### 6 | $UserName = "Johnny Smith" #Change this to match your User Name 7 | $PhotoPath = "C:\BoxBuild\JSmith.jpg" #Change this path to match your environment 8 | ### End Variables ### 9 | 10 | Import-PSSession $(New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Authentication Basic -AllowRedirection -Credential $(Get-Credential)) 11 | 12 | Get-UserPhoto $UserName 13 | 14 | Remove-UserPhoto $UserName 15 | 16 | Set-UserPhoto $UserName –PictureData ([System.IO.File]::ReadAllBytes($PhotoPath)) 17 | 18 | Get-UserPhoto $UserName -------------------------------------------------------------------------------- /PowerShell/Working/o365/GetExchangeOnlineDistributionListMembers.ps1: -------------------------------------------------------------------------------- 1 | ## MSOnline: PowerShell Script to Connect to Exchange Online and Get Distribution Lists Group Members (o365) ## 2 | 3 | ## Overview: Script that connects to Office 365 Exchange Online and retrieves Distribution Lists Group Members 4 | 5 | ## Usage: Change the '-Identity' parameter for the 'Get-DistributionGroup' to match a specific group or multiple groups with the wild card '*' asterix 6 | 7 | ## Resource: http://www.lazywinadmin.com/2015/08/powershello365-get-distribution-groups.html#more 8 | 9 | Import-PSSession $(New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Authentication Basic -AllowRedirection -Credential $(Get-Credential)) 10 | 11 | (Get-DistributionGroup -Identity 'GroupName*').identity | ForEach-Object{ 12 | $DistributionGroupName = $_ 13 | Get-DistributionGroupMember -Identity $_ | ForEach-Object{ 14 | [PSCustomObject]@{ 15 | DistributionGroup = $DistributionGroupName 16 | MemberName = $_.Name 17 | EmailAddress =$_.primarysmtpaddress 18 | #Other recipientproperties here 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PowerShell/Working/o365/GetMSOnlineGroupsLastDirSyncTime.ps1: -------------------------------------------------------------------------------- 1 | ## MSOnline: PowerShell Script to Get All MSOnline Groups Last Sync Time via DirSync (o365) ## 2 | 3 | ## Connect to MSOnline Tenant 4 | Import-Module MSOnline 5 | Import-Module MSOnlineExtended 6 | $cred=Get-Credential 7 | Connect-MsolService -Credential $cred 8 | 9 | ## Retrieve the Groups that have a last DirSyncTime 10 | $objDistributionGroups = Get-MSolgroup -All | where lastdirsynctime -ne $null 11 | Foreach 12 | ($objDistributionGroup in $objDistributionGroups) 13 | 14 | { 15 | 16 | Write-Output "$($objDistributionGroup.DisplayName + ', ' + $objDistributionGroup.EmailAddress + ', ' + $objDistributionGroup.LastDirSyncTime)" 17 | 18 | } 19 | -------------------------------------------------------------------------------- /PowerShell/Working/o365/GetMSOnlineGroupsWithoutLastDirSyncTime.ps1: -------------------------------------------------------------------------------- 1 | ## MSOnline: PowerShell Script to Get All MSOnline Groups that have not been Synchronised via DirSync (o365) ## 2 | 3 | ## Connect to MSOnline Tenant 4 | Import-Module MSOnline 5 | Import-Module MSOnlineExtended 6 | $cred=Get-Credential 7 | Connect-MsolService -Credential $cred 8 | 9 | ## Retrieve the Groups that don't have a last DirSyncTime 10 | $objDistributionGroups = Get-MSolgroup -All | where lastdirsynctime -eq $null 11 | Foreach 12 | ($objDistributionGroup in $objDistributionGroups) 13 | 14 | { 15 | 16 | Write-host "$($objDistributionGroup.DisplayName + ', ' + $objDistributionGroup.EmailAddress)" 17 | 18 | } 19 | -------------------------------------------------------------------------------- /PowerShell/Working/o365/GetMSOnlineTenantID.ps1: -------------------------------------------------------------------------------- 1 | ## MSOnline: PowerShell Command to Get you Office 365 (o365) Tenant ID Value (GUID) ## 2 | 3 | ## Tip: You can also get the Tenant ID from the Azure Active Directory Module under Properties - Directory ID: https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Properties 4 | 5 | ## Resource: http://tomtalks.uk/2015/09/how-to-get-your-office-365-tenant-id 6 | 7 | $TenantPrefix = "YourTenantName" #Change the prefix here to match your tenant name 8 | 9 | (Invoke-WebRequest https://login.windows.net/$TenantPrefix.onmicrosoft.com/.well-known/openid-configuration|ConvertFrom-Json).token_endpoint.Split(‘/’)[3] -------------------------------------------------------------------------------- /PowerShell/Working/o365/GetMSOnlineUserLicenses.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/o365/GetMSOnlineUserLicenses.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/o365/O365-Fed-MetaData-Update-Task-Installation.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/o365/O365-Fed-MetaData-Update-Task-Installation.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/o365/SharePointOnline/SPOnlineDeleteSiteCollection.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Online: PowerShell SharePoint Online Module Script to Delete a Site Collection (SPOnline) ## 2 | 3 | ## Overview: PowerShell Script that uses the SharePoint Online Module 'Remove-SPOSite' cmdlet to delete a site collection. This site collection is then moved to the Recycle Bin 4 | 5 | ## Note: To delete a site collection permanently, first move the site collection to the Recycle Bin by using the 'Remove-SPOSite' cmdlet, and then delete it by using the 'Remove-SPODeletedSite' cmdlet. 6 | 7 | ## Usage: Replace the 'contoso' placeholder value under 'Connect-SPOService' with your own tenant prefix and provide the Site Collection URL under the '$SiteURL' variable 8 | 9 | ## Resource: https://technet.microsoft.com/en-us/library/fp161377.aspx 10 | 11 | $SiteURL = "https://contoso.sharepoint.com/sites/sitetoremove" 12 | 13 | Import-Module Microsoft.Online.Sharepoint.PowerShell 14 | $credential = Get-credential 15 | Connect-SPOService -url https://contoso-admin.sharepoint.com -Credential $credential 16 | 17 | Remove-SPOSite -Identity $SiteURL -NoWait -------------------------------------------------------------------------------- /PowerShell/Working/o365/SharePointOnline/SPOnlineEnableDisableCustomScriptForSiteCollections.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Online: PowerShell SharePoint Online Module Script to Enable / Disable Custom Script Features at Site Collection Level ## 2 | 3 | ## Usage: Edit the variables below to match your requirements and run the script 4 | 5 | ## Resources: https://emadmagdy.wordpress.com/2015/06/24/sharepoint-onlineenabling-custom-script 6 | 7 | ### Start Variables ### 8 | $Tenant = "YourTenant" 9 | $SiteURL = "https://YourSPOsite.sharepoint.com" 10 | $CustomScriptFlag = 0 #Change this boolean value to 1 if you want to disable Custom Script features 11 | ### End Variables ### 12 | 13 | Import-Module Microsoft.Online.Sharepoint.PowerShell 14 | $credential = Get-credential 15 | Connect-SPOService -url ("https://" + "$Tenant" + "-admin.sharepoint.com") -Credential $credential 16 | 17 | #Enable / Disable Custom Script at Site Collection Level 18 | Set-SPOsite $SiteURL -DenyAddAndCustomizePages $CustomScriptFlag 19 | 20 | #Check the properties of the Site Collection (Note: these changes can take a while to take effect on o365) 21 | Get-SPOSite $SiteURL |fl -------------------------------------------------------------------------------- /PowerShell/Working/o365/SharePointOnline/SPOnlineGetAllSiteCollectionDetails.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Online: PowerShell SharePoint Online Module Script to Get Deatils on All Site Collections in a Tenant (SPOnline) ## 2 | 3 | ## Overview: PowerShell Script that uses the SharePoint Online Module to Get useful details on All site collections using the 'Get-SPOSite' commandlet 4 | 5 | ## Usage: Replace the 'contoso' placeholder value under 'Connect-SPOService' with your own tenant prefix and run the script 6 | 7 | ## Resource: http://3sharp.com/blog/use-powershell-to-automate-site-collection-setup-in-sharepoint-online 8 | 9 | Import-Module Microsoft.Online.Sharepoint.PowerShell 10 | $credential = Get-credential 11 | Connect-SPOService -url https://contoso-admin.sharepoint.com -Credential $credential 12 | 13 | Get-SPOSite -Detailed | Sort-Object StorageUsageCurrent -Descending | Format-Table Url, Template, WebsCount, StorageUsageCurrent, StorageQuota, ResourceUsageCurrent, LastContentModifiedDate -AutoSize -------------------------------------------------------------------------------- /PowerShell/Working/o365/SharePointOnline/SPOnlineRemoveDeletedSiteCollection.ps1: -------------------------------------------------------------------------------- 1 | ## SharePoint Online: PowerShell SharePoint Online Module Script to remove a Deleted Site Collection from the Recycle Bin (SPOnline) ## 2 | 3 | ## Overview: PowerShell Script that uses the SharePoint Online Module 'Remove-SPODeletedSite' cmdlet to permanently remove a deleted site collection from the Recycle Bin 4 | 5 | ## Usage: Replace the 'contoso' placeholder value under 'Connect-SPOService' with your own tenant prefix and provide the Site Collection URL under the '$SiteURL' variable 6 | 7 | ## Resource: https://technet.microsoft.com/en-us/library/fp161368.aspx 8 | 9 | $SiteURL = "https://contoso.sharepoint.com/sites/sitetoremove" 10 | 11 | Import-Module Microsoft.Online.Sharepoint.PowerShell 12 | $credential = Get-credential 13 | Connect-SPOService -url https://contoso-admin.sharepoint.com -Credential $credential 14 | 15 | Remove-SPODeletedSite -Identity $SiteURL -------------------------------------------------------------------------------- /PowerShell/Working/quest/EnumOperatingSystems.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/PowerShell/Working/quest/EnumOperatingSystems.ps1 -------------------------------------------------------------------------------- /PowerShell/Working/security/EncryptCredentialsForPSRemoting.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell Script to store and use the same credentials for PSRemoting scripting ## 2 | 3 | # Set your PowerShell Variables here 4 | 5 | $PasswordFileLocation = "C:\FolderName\psremotingpassword.txt" #Change the path here to suit your environment 6 | $PSRemotingUser = "DOMAIN\User" #Change the domain and user here to suit your environment 7 | $RemoteMachine = "MachineName" #Change the remote machine name here to suit your environment 8 | 9 | # Get host input to encrypt PSRemoting password to an encrypted text file 10 | 11 | Read-Host "Please enter your PSRemoting password" -AsSecureString | ConvertFrom-SecureString | out-file $PasswordFileLocation 12 | 13 | # Now read the PSRemoting password to a SecureString 14 | 15 | $pwd = Get-Content $PasswordFileLocation | ConvertTo-SecureString 16 | 17 | # Now create the credential to be used 18 | 19 | $crd = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $PSRemotingUser,$pwd 20 | 21 | # Now use your credentials for a new PSRemoting session 22 | 23 | Enter-PSSession -ComputerName $RemoteMachine -Authentication CredSSP -Credential $crd -------------------------------------------------------------------------------- /PowerShell/Working/security/GenerateSecurePasswords.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: Simple Function to generate Secure Passwords ## 2 | 3 | Function GeneratePassword { 4 | param( 5 | [int] $len = 10, #Change the length here to reflect the numbe of characters you want your password to be 6 | [string] $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_!@#$%^&*()_" 7 | ) 8 | $bytes = new-object "System.Byte[]" $len 9 | $rnd = new-object System.Security.Cryptography.RNGCryptoServiceProvider 10 | $rnd.GetBytes($bytes) 11 | $result = "" 12 | for( $i=0; $i -lt $len; $i++ ) 13 | { 14 | $result += $chars[ $bytes[$i] % $chars.Length ] 15 | } 16 | $result 17 | } 18 | 19 | GeneratePassword -------------------------------------------------------------------------------- /PowerShell/Working/web/WebPageLoadTimesTest.ps1: -------------------------------------------------------------------------------- 1 | ## PowerShell: PowerShell Function that Measures Page Load Times and HTTP Protocol Status Codes ## 2 | 3 | <# 4 | 5 | Overview: PowerShell Function that uses the 'System.Net.WebClient' to Measure Page Load Times, and HTTP Protocol Status Codes over a specified number of Times 6 | 7 | Usage Example: 8 | 9 | MeasurePageLoad "https://google.com" -Times 10 10 | 11 | #> 12 | 13 | Function MeasurePageLoad { 14 | 15 | param($URL, $Times) 16 | $i = 1 17 | While ($i -lt $Times) 18 | {$Request = New-Object System.Net.WebClient 19 | $Request.UseDefaultCredentials = $true 20 | $Start = Get-Date 21 | $PageRequest = $Request.DownloadString($URL) 22 | $TimeTaken = ((Get-Date) – $Start).Totalseconds 23 | $StatusCode = [int][system.net.httpstatuscode]::ok 24 | $Request.Dispose() 25 | Write-Host Request $i took $TimeTaken Seconds with a $StatusCode HTTP Status Code -ForegroundColor Green 26 | $i ++} 27 | } -------------------------------------------------------------------------------- /SQLServer/Working/AzureSQLEnumDatabaseUsersAndRoles.sql: -------------------------------------------------------------------------------- 1 | /* Azure SQL Server: SQL Command to show Database Permissions on an Azure SQL Instance */ 2 | 3 | --Resource: https://blobeater.blog/2017/05/22/ad-authentication-and-azure-sql-database/ 4 | 5 | SELECT 6 | p.name, 7 | prm.permission_name, 8 | prm.class_desc, 9 | prm.state_desc, 10 | p2.name as 'Database role', 11 | p3.name as 'Additional database role' 12 | FROM sys.database_principals p 13 | JOIN sys.database_permissions prm 14 | ON p.principal_id = prm.grantee_principal_id 15 | LEFT JOIN sys.database_principals p2 16 | ON prm.major_id = p2.principal_id 17 | LEFT JOIN sys.database_role_members r 18 | ON p.principal_id = r.member_principal_id 19 | LEFT JOIN sys.database_principals p3 20 | ON r.role_principal_id = p3.principal_id 21 | WHERE p.name <> 'public' 22 | ORDER BY p.name -------------------------------------------------------------------------------- /SQLServer/Working/SQLAttachDatabase.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: SQL Command to Attach Database Files to a SQL Instance */ 2 | 3 | USE [master] 4 | CREATE DATABASE [Your_Database_Name] ON 5 | ( FILENAME = 'U:\MSSQL\Data\Your_Database_Name.mdf'),--Path to database 'mdf' file 6 | ( FILENAME = 'N:\MSSQL\Data\Your_Database_Name.ldf') --Path to transaction log 'ldf' file 7 | FOR ATTACH 8 | GO -------------------------------------------------------------------------------- /SQLServer/Working/SQLBackupDatabasesToDiskWithCopyOnly.sql: -------------------------------------------------------------------------------- 1 | /* Simple script to backup all SQL Server databases with Copy Only switch */ 2 | 3 | DECLARE @name VARCHAR(50) -- database name 4 | DECLARE @path VARCHAR(256) -- path for backup files 5 | DECLARE @fileName VARCHAR(256) -- filename for backup 6 | DECLARE @fileDate VARCHAR(20) -- used for file name 7 | 8 | SET @path = 'M:\MSSQL10_50.SQL5\MSSQL\Backup\' -- file path here (keep '\' at end of path) -- 9 | 10 | SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) 11 | 12 | DECLARE db_cursor CURSOR FOR 13 | SELECT name 14 | FROM master.dbo.sysdatabases 15 | WHERE name NOT IN ('master','model','msdb','tempdb') 16 | 17 | OPEN db_cursor 18 | FETCH NEXT FROM db_cursor INTO @name 19 | 20 | WHILE @@FETCH_STATUS = 0 21 | BEGIN 22 | SET @fileName = @path + @name + '_' + @fileDate + '.BAK' 23 | BACKUP DATABASE @name TO DISK = @fileName with COPY_ONLY -- use this switch to prevent affecting the normal backup / restore cycle -- 24 | 25 | 26 | FETCH NEXT FROM db_cursor INTO @name 27 | END 28 | 29 | CLOSE db_cursor 30 | DEALLOCATE db_cursor 31 | -------------------------------------------------------------------------------- /SQLServer/Working/SQLBackupHistoryAnalysis.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server Backup History Analysis */ 2 | 3 | SELECT s.database_name, 4 | m.physical_device_name, 5 | cast(s.backup_size/1000000 as varchar(14))+' '+'MB' as bkSize, 6 | CAST (DATEDIFF(second,s.backup_start_date , s.backup_finish_date)AS VARCHAR(4))+' '+'Seconds' TimeTaken, 7 | s.backup_start_date, 8 | CASE s.[type] 9 | WHEN 'D' THEN 'Full' 10 | WHEN 'I' THEN 'Differential' 11 | WHEN 'L' THEN 'Transaction Log' 12 | END as BackupType, 13 | s.server_name, 14 | s.recovery_model 15 | FROM msdb.dbo.backupset s 16 | inner join msdb.dbo.backupmediafamily m 17 | ON s.media_set_id = m.media_set_id 18 | WHERE s.database_name IN ( 19 | -- List your databases here, and remember to leave off the ',' at the end of the last database -- 20 | 'SPS_ECMPortalContentDB', 21 | 'SPS_PortalContentDB' 22 | ) 23 | AND s.backup_start_date > '2011-10-01 00:00:00.000' -- change this to your date and time of backup -- 24 | ORDER BY database_name, backup_start_date, backup_finish_date -------------------------------------------------------------------------------- /SQLServer/Working/SQLDropDatabases.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: SQL Query To List All User Databases To Bulk DROP Them*/ 2 | 3 | -- Usage: Change 'Query Results' options to 'Results to text' and run the query. Paste your results in another query window and run. 4 | -- Environments: SQL Server 2008 / 2012 5 | 6 | USE master; 7 | Go 8 | SELECT 'DROP DATABASE '+ name 9 | FROM sys.databases WHERE name like 'DEV_%'; --Change your name here 10 | GO -------------------------------------------------------------------------------- /SQLServer/Working/SQLEnumClientConnectionDetails.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: Queries to Check Connections to an Instance along with a Client Connections Count */ 2 | 3 | -- https://www.mssqltips.com/sqlservertip/3171/identify-sql-server-databases-that-are-no-longer-in-use/ 4 | -- http://www.brentozar.com/archive/2014/05/4-lightweight-ways-tell-database-used/ 5 | 6 | -- Detailed SQL Server Connection Information 7 | SELECT @@ServerName AS SERVER 8 | ,NAME 9 | ,login_time 10 | ,last_batch 11 | ,getdate() AS DATE 12 | ,STATUS 13 | ,hostname 14 | ,program_name 15 | ,nt_username 16 | ,loginame 17 | FROM sys.databases d 18 | LEFT JOIN sysprocesses sp ON d.database_id = sp.dbid 19 | WHERE database_id NOT BETWEEN 0 20 | AND 4 21 | AND loginame IS NOT NULL 22 | 23 | -- SQL Server User / Client Connection Count 24 | SELECT @@ServerName AS server 25 | ,NAME AS dbname 26 | ,COUNT(STATUS) AS number_of_connections 27 | ,GETDATE() AS timestamp 28 | FROM sys.databases sd 29 | LEFT JOIN sysprocesses sp ON sd.database_id = sp.dbid 30 | WHERE database_id NOT BETWEEN 1 AND 4 31 | GROUP BY NAME -------------------------------------------------------------------------------- /SQLServer/Working/SQLEnumClientConnections.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: Query to check connections on port 1433 or other ports */ 2 | 3 | SELECT c.session_id, c.local_tcp_port, s.login_name, s.host_name, s.program_name 4 | FROM sys.dm_exec_connections AS c INNER JOIN 5 | sys.dm_exec_sessions AS s on c.session_id = s.session_id 6 | -- WHERE c.local_tcp_port <> 1433 -- Not equal to port '1433' -- 7 | WHERE c.local_tcp_port = 1433 -- Equal to port '1433' -- 8 | -------------------------------------------------------------------------------- /SQLServer/Working/SQLEnumDatabaseSizeAndFileGrowth.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/SQLServer/Working/SQLEnumDatabaseSizeAndFileGrowth.sql -------------------------------------------------------------------------------- /SQLServer/Working/SQLEnumDatabaseUsersAndRoles.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: Script To Query Users And Roles Against a Database */ 2 | 3 | -- Environments: SQL Server 2008 / 2012 4 | 5 | WITH Roles_CTE(Role_Name, Username) 6 | AS 7 | ( 8 | SELECT 9 | User_Name(sm.[groupuid]) as [Role_Name], 10 | user_name(sm.[memberuid]) as [Username] 11 | FROM [sys].[sysmembers] sm 12 | ) 13 | 14 | SELECT 15 | Roles_CTE.Role_Name, 16 | [DatabaseUserName] = princ.[name], 17 | [UserType] = CASE princ.[type] 18 | WHEN 'S' THEN 'SQL User' 19 | WHEN 'U' THEN 'Windows User' 20 | WHEN 'G' THEN 'Windows Group' 21 | WHEN 'A' THEN 'Application Role' 22 | WHEN 'R' THEN 'Database Role' 23 | WHEN 'C' THEN 'User mapped to a certificate' 24 | WHEN 'K' THEN 'User mapped to an asymmetric key' 25 | END 26 | FROM 27 | sys.database_principals princ 28 | JOIN Roles_CTE on Username = princ.name 29 | where princ.type in ('S', 'U', 'G', 'A', 'R', 'C', 'K') 30 | ORDER BY princ.name 31 | -------------------------------------------------------------------------------- /SQLServer/Working/SQLEnumDatabasesAndLogFileSizes.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: Query to return Database and Log File Sizes in KB / MB Along with Log File Used Size and Log File Percentage (%) Used */ 2 | 3 | SELECT instance_name AS DatabaseName, 4 | [Data File(s) Size (KB)], ROUND([Data File(s) Size (KB)] / 1024, 2) AS 'Data File(s) Size (MB)', 5 | [LOG File(s) Size (KB)], ROUND([LOG File(s) Size (KB)] / 1024, 2) AS 'LOG File(s) Size (MB)', 6 | [Log File(s) Used Size (KB)], ROUND([Log File(s) Used Size (KB)] / 1024, 2) AS 'Log File(s) Used Size (MB)', 7 | [Percent Log Used] 8 | FROM 9 | ( 10 | SELECT * 11 | FROM sys.dm_os_performance_counters 12 | WHERE counter_name IN 13 | ( 14 | 'Data File(s) Size (KB)', 15 | 'Log File(s) Size (KB)', 16 | 'Log File(s) Used Size (KB)', 17 | 'Percent Log Used' 18 | ) 19 | AND instance_name != '_Total' 20 | ) AS Src 21 | PIVOT 22 | ( 23 | MAX(cntr_value) 24 | FOR counter_name IN 25 | ( 26 | [Data File(s) Size (KB)], 27 | [LOG File(s) Size (KB)], 28 | [Log File(s) Used Size (KB)], 29 | [Percent Log Used] 30 | ) 31 | ) AS pvt 32 | -------------------------------------------------------------------------------- /SQLServer/Working/SQLEnumFileGrowth.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: Query To Get File Growth Settings And Status For All Databases In An Instance */ 2 | -- Environments: SQL Server 2008 / 2012 3 | use master 4 | go 5 | select b.name DB_Name, a.name Logical_name, a.filename File_Name, 6 | cast((a.size * 8.00) / 1024 as numeric(12,2)) as DB_Size_in_MB, 7 | case when a.growth > 100 then 'In MB' else 'In Percentage' end File_Growth, 8 | cast(case when a.growth > 100 then (a.growth * 8.00) / 1024 9 | else (((a.size * a.growth) / 100) * 8.00) / 1024 10 | end as numeric(12,2)) File_Growth_Size_in_MB, 11 | case when ( maxsize = -1 or maxsize=268435456 ) then 'AutoGrowth Not Restricted' else 'AutoGrowth Restricted' end AutoGrowth_Status 12 | from sysaltfiles a 13 | join sysdatabases b on a.dbid = b.dbid 14 | where DATABASEPROPERTYEX(b.name, 'status') = 'ONLINE' 15 | order by b.name -------------------------------------------------------------------------------- /SQLServer/Working/SQLEnumTableSizes.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/SQLServer/Working/SQLEnumTableSizes.sql -------------------------------------------------------------------------------- /SQLServer/Working/SQLGetHostClusterNodesDatabaseLocationsVolumesSizes.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/SQLServer/Working/SQLGetHostClusterNodesDatabaseLocationsVolumesSizes.sql -------------------------------------------------------------------------------- /SQLServer/Working/SQLRestoreHistoryAnalysis.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: Query to view SQL Server Database Restore History */ 2 | 3 | USE msdb ; 4 | SELECT 5 | DISTINCT 6 | DBRestored = destination_database_name , 7 | RestoreDate = restore_date , 8 | SourceDB = b.database_name , 9 | BackupDate = backup_start_date 10 | FROM RestoreHistory h 11 | JOIN MASTER..sysdatabases sd ON sd.name = h.destination_database_name 12 | INNER JOIN BackupSet b ON h.backup_set_id = b.backup_set_id 13 | INNER JOIN BackupFile f ON f.backup_set_id = b.backup_set_id 14 | GROUP BY destination_database_name , 15 | restore_date , 16 | b.database_name , 17 | backup_start_date 18 | ORDER BY RestoreDate DESC 19 | GO 20 | -------------------------------------------------------------------------------- /SQLServer/Working/SQLSharePointDatabaseNamesAgainstGUIDs.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: Query to Identify SharePoint Database Names against their GUID IDs */ 2 | -- Usage: Works on both MOSS 2007 and SharePoint Server 2010 Farm Config DBs 3 | -- Run these queries against your 'farm config' DB 4 | Select ID, Name from objects 5 | where properties like 6 | '%Microsoft.SharePoint.Administration.SPContentDatabase%m_nWarningSiteCount%' 7 | 8 | -- Or if you have given your DBs unique name prefixes -- 9 | Select ID, Name from objects 10 | where Name like '%SPS_%DB%' -------------------------------------------------------------------------------- /SQLServer/Working/SQLSharePointFilePathLengthQueries.sql: -------------------------------------------------------------------------------- 1 | /* SharePoint: SQL Query to list Folders and Files Length Counts for Libraries in your content DB */ 2 | 3 | -- Usage: Works on content databases for both MOSS 2007 and SharePoint Server 2010 / 2013 Farms 4 | 5 | select top 100 --Change this value to the 'top' number of documents you want to report on 6 | 7 | SUM(len(dirname)+len(leafname)) as Total, 8 | 9 | len(dirname) as DirLength, 10 | 11 | dirname, 12 | 13 | len(leafname) as LeafLength, 14 | 15 | leafname 16 | 17 | from alldocs with (NOLOCK) 18 | 19 | where DeleteTransactionID = 0x 20 | 21 | and IsCurrentVersion= 1 22 | 23 | group by dirname, leafname 24 | 25 | having cast(SUM(len(dirname)+len(leafname)) as int) > 260 --Change this value to the 'Total' number of characters you want to query 26 | 27 | order by total desc -------------------------------------------------------------------------------- /SQLServer/Working/SQLSharePointListMySites.sql: -------------------------------------------------------------------------------- 1 | /* SharePoint Server: SQL Query to Show All User Profiles With a My Site */ 2 | -- Usage: Should work on MOSS 2007 and SharePoint Server 2010 Farms 3 | -- Needs to be run against your ProfileDB 4 | -- With SharePoint Server 2010 there is an additional table called 'MySiteDeletionStatus' 5 | 6 | SELECT PropertyVal, p.* 7 | FROM dbo.UserProfileValue v inner join dbo.UserProfile_Full p on p.RecordID=v.RecordID 8 | where PropertyID=22 and PropertyVal is not null -------------------------------------------------------------------------------- /SQLServer/Working/SQLSharePointListTemplateNamesAndIDs.sql: -------------------------------------------------------------------------------- 1 | /* SharePoint: SQL Query to List All List Template Titles and SP List Template Type IDs used in your content DB */ 2 | -- Usage: Works on content databases for both MOSS 2007 and SharePoint Server 2010 Farms 3 | -- Resource: http://techtrainingnotes.blogspot.ch/2008/01/sharepoint-registrationid-list-template.html 4 | 5 | -- Common List Template Type Ids -- 6 | -- 100 Generic list 7 | -- 101 Document library 8 | -- 102 Survey 9 | -- 103 Links list 10 | -- 104 Announcements list 11 | -- 105 Contacts list 12 | -- 106 Events list 13 | -- 107 Tasks list 14 | -- 108 Discussion board 15 | -- 109 Picture library 16 | -- 110 Data sources 17 | -- 111 Site template gallery 18 | -- 112 User Information list 19 | -- 113 Web Part gallery 20 | -- 114 List template gallery 21 | -- 115 XML Form library 22 | 23 | USE YourContentDBName --Change this to your Content Database name 24 | SELECT tp_Title, tp_BaseType, tp_ServerTemplate, tp_Description 25 | FROM AllLists 26 | ORDER BY tp_ServerTemplate, tp_Title -------------------------------------------------------------------------------- /SQLServer/Working/SQLSharePointTruncateUsageAndHealthDatabase.sql: -------------------------------------------------------------------------------- 1 | /* SharePoint Server: SQL Query To Truncate Usage And Health Data Collection Content */ 2 | 3 | -- Overview: Use the SQL below in a situation where your usage and health data collection service causes massive growth in the content database 4 | -- Environments: SP2013 Farms 5 | -- Usage: Run the SQL below on your 'UsageAndHealth' content database to Truncate data from the table 6 | -- Resource: http://www.bondbyte.com/Blog/tabid/55/EntryId/25/SharePoint-2013-unexpected-database-growth.aspx 7 | 8 | DECLARE @TableName AS VARCHAR(MAX) 9 | 10 | DECLARE table_cursor CURSOR 11 | FOR 12 | SELECT TABLE_NAME 13 | FROM INFORMATION_SCHEMA.TABLES 14 | WHERE TABLE_TYPE = 'BASE TABLE' 15 | AND TABLE_NAME LIKE '%_Partition%' 16 | OPEN table_cursor 17 | 18 | FETCH NEXT FROM table_cursor INTO @TableName 19 | 20 | WHILE @@FETCH_STATUS = 0 21 | BEGIN 22 | DECLARE @SQLText AS NVARCHAR(4000) 23 | 24 | SET @SQLText = 'TRUNCATE TABLE ' + @TableName 25 | 26 | EXEC sp_executeSQL @SQLText 27 | 28 | FETCH NEXT FROM table_cursor INTO @TableName 29 | END 30 | 31 | CLOSE table_cursor 32 | DEALLOCATE table_cursor -------------------------------------------------------------------------------- /SQLServer/Working/SQLShrinkTransactionLogs.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: Shrink Database Transaction log file sizes */ 2 | 3 | -- In Production environments; you should always do a full database backup prior to and after this shrink process -- 4 | -- Environments: SQL Server 2008 / 2012 -- 5 | 6 | USE SharePoint_Config -- Data database file name, use [] around the name if you're getting errors locating the database -- 7 | GO 8 | Alter Database SharePoint_Config Set Recovery Simple -- Data database file name -- 9 | DBCC SHRINKFILE ('SharePoint_Config_log', 100) -- Log file database name and size in MB -- 10 | Alter Database SharePoint_Config Set Recovery Full -- Data database file name -- 11 | 12 | -- Now check the recovery model for your database to make sure it's back to FULL if required -- 13 | 14 | USE Master 15 | SELECT Name, Recovery_Model_Desc FROM Sys.Databases 16 | where Name = 'SharePoint_Config' 17 | -------------------------------------------------------------------------------- /SQLServer/Working/SQLTopIOQueries.sql: -------------------------------------------------------------------------------- 1 | /* SQL Server: Query to List SQL Queries That Use The Most I/O */ 2 | 3 | SELECT TOP 10 --Change this to how many top queries you want to return 4 | [Total IO] = (qs.total_logical_reads + qs.total_logical_writes) 5 | , [Average IO] = (qs.total_logical_reads + qs.total_logical_writes) / 6 | qs.execution_count 7 | , qs.execution_count 8 | , SUBSTRING (qt.text,(qs.statement_start_offset/2) + 1, 9 | ((CASE WHEN qs.statement_end_offset = -1 10 | THEN LEN(CONVERT(NVARCHAR(MAX), qt.text)) * 2 11 | ELSE qs.statement_end_offset 12 | END - qs.statement_start_offset)/2) + 1) AS [Individual Query] 13 | , qt.text AS [Parent Query] 14 | , DB_NAME(qt.dbid) AS DatabaseName 15 | , qp.query_plan 16 | FROM sys.dm_exec_query_stats qs 17 | CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as qt 18 | CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp 19 | ORDER BY [Total IO] DESC 20 | -------------------------------------------------------------------------------- /ServiceNow/ServiceNowRecordProducerPopulateIncidentRecord.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chrisdee/Scripts/1a4bdb393b93e228b182ec3c057926e71687b20b/ServiceNow/ServiceNowRecordProducerPopulateIncidentRecord.js --------------------------------------------------------------------------------