-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathoneliners.ps1
66 lines (51 loc) · 2.7 KB
/
oneliners.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<#
.README
A collection of one-line commands or as near as to do simple jobs.
#>
# Never let this script run alone
exit 1
# .Remove all scripts for users logon on the domain.
get-aduser -Property ScriptPath -Filter {ScriptPath -notlike $false} | Set-ADUser -ScriptPath $null
# Disable offline files
& "sc config CscService start=disabled"
new-itemproperty -path "HKLM:\SYSTEM\CurrentControlSet\Services\Csc\Parameters" -name FormatDatabase -propertytype DWORD -value 1
# Get a batch of the status of ligcator for a whole bunch of rooms
Import-Module Util
$cred = Get-Credential 08105curric\j
$r40 = New-ComputerList -Room 40 -Computer (1..26) -FQDN | New-PSSession -Credential $cred -Authentication Credssp
$r38 = New-ComputerList -Room 38 -Computer (1..13) -FQDN | New-PSSession -Credential $cred -Authentication Credssp
$r37 = New-ComputerList -Room 37 -Computer (1..32) -FQDN | New-PSSession -Credential $cred -Authentication Credssp
$computers = $r40 + $r38 + $r37
invoke-command -Session $computers -ScriptBlock {
Set-ExecutionPolicy allsigned
Import-Module "\\uhserver1\HomeStaff\Home\j.bennett\ps\Application\Application.psm1"
Get-Application -name Logicator
} | select computername,name,version | format-table -AutoSize | out-file Output -Append
# Replace all placeholder values with the actual username for H drives.
# Odd problem with year 7
Get-ADGroupMember -Identity "Intake 2014" |
Get-ADuser -Properties "HomeDirectory" |
Where-Object HomeDirectory -Match "%username%" |
ForEach-Object {
Set-ADuser -Identity $_ -HomeDirectory ($_.homeDirectory -replace "%username%", $_.samAccountName)
}
# Test if powershell remoting is enabled on a selection of computers
Import-module ActiveDirectory
$computer = get-ADComputer -Filter * -searchBase "OU=R50,OU=Computers,OU=Upholland,DC=upholland,DC=lancsngfl,DC=ac,DC=uk"
foreach($comp in $computer){
invoke-command -ComputerName $comp.name -ScriptBlock {
get-service Netlogon | select-object Displayname,status
}
}
Remove-Variable computer
# wipe the local profiles of selected user groups on target machines
import-module util
$s = New-ComputerList -Room 37 -Computer (2..32) | New-PSSession
invoke-command -Session $s -ScriptBlock {
get-childitem -Directory "C:/Users" -Include "14*" | Remove-Item -Force
}
# reset a whole year group password
Get-ADGroupMember -Identity "Intake 2014" |
Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "password" -Force)
# Strip white space (capital matches the NOT value), force to replace the contents of the existing file, encode so Brackets can open the file
(get-content .\schedule-time.txt) -match "\S" | Out-File .\schedule-time.txt -Force -Encoding utf8