Go to ...


A Better Technical Repository

RSS Feed


Powershell: Pull all user’s displaynames, emailaddress, samaccountname

Install needed powershell modules: import-module servermanager Add-WindowsFeature -Name “RSAT-AD-PowerShell” -IncludeAllSubFeature import-module activedirectory Run the following command: Get-ADUser -Filter * -Properties DisplayName, EmailAddress, SamAccountName | select DisplayName, EmailAddress, SamAccountName | Export-CSV “C:\Email_Addresses.csv” By: Timothy Jay Conrad

Powershell: Set the script running security level

Using the Set-ExecutionPolicy Cmdlet Changing the Windows PowerShell Script Execution Policy   The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer. Windows PowerShell has four different execution policies: Restricted – No scripts can be run. Windows PowerShell can be used only in interactive

Programming: A powershell way to check to see if a service has stopped and then start it.

To check to see if a service is running and then start it if it is not, create a powershell file with the following code. $ServiceName = ‘YourExactServiceName’ $arrService = Get-Service -Name $ServiceName while ($arrService.Status -ne ‘Running’) { Start-Service $ServiceName write-host $arrService.status write-host ‘Service starting’ Start-Sleep -seconds 60 $arrService.Refresh() if ($arrService.Status -eq ‘Running’) { Write-Host

Powershell: Send keyboard input to the screen

Here is a very basic way to send keyboard inputs to the screen on a looped time interval: while ($true) { $minutes = 1 $myShell = New-Object -com “Wscript.Shell” for ($i = 0; $i -lt $minutes; $i++) { Start-Sleep -Seconds 30 $myShell.sendkeys(” “) } }

Older Posts››