This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Note: | |
If you're going to schedule this task to run, use the following action: | |
Program/script: powershell | |
add arguments: -command &{[path to find_pc_owner.ps1]} | |
Start in: [the working directory] | |
see: http://blogs.technet.com/b/heyscriptingguy/archive/2011/0/12/use-scheduled-tasks-to-run-powershell-commands-on-windows.aspx | |
#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://poshcode.org/2049 | |
#http://forums.codeguru.com/showthread.php?491406-RESOLVED-Touch-Enable-Disable-Script&p=1911164#post1911164 | |
if (-not ("win32.nativemethods" -as [type])) { | |
# import sendmessagetimeout from win32 | |
add-type -Namespace Win32 -Name NativeMethods -MemberDefinition @" | |
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam, uint fuFlags, uint uTimeout, out UIntPtr lpdwResult); | |
"@ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ref | |
## http://blogs.technet.com/b/heyscriptingguy/archive/2011/06/13/use-powershell-invoke-command-for-remoting.aspx | |
## http://www.powershellmagazine.com/2013/04/10/pstip-wait-for-a-service-to-reach-a-specified-status/ | |
## http://stackoverflow.com/a/3008717/843000 | |
## http://support.microsoft.com/kb/2509997 | |
Invoke-Command -scriptblock { | |
#is this case, I am cleaning up pending updates due to an issue with a deployed update (error 1638) | |
$wuausvc = get-service wuauserv | |
$wuausvc.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param( | |
[string]$targetuser, | |
[string]$granteduser, | |
[string]$accessright | |
) | |
$targetuser=$targetuser+":" | |
write-host "previous to action permission list:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
http://techibee.com/tips/powershell-script-to-get-ilo-version-and-server-model-remotely/572 | |
Note: | |
If you're going to schedule this task to run, use the following action: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#query for KB on all machines in a given OU (instead of get-adcomputer, try get-content and a file with a list of IPs or hostnames for the same effect) | |
#note that the get-wmiobject is optimized to only request specific hotfixids, before I would request all records are parse client size (ewww) | |
$contents = $( get-adcomputer -filter "objectCategory -eq 'computer'" -SearchBase "OU=New York,DC=contoso,DC=corp" | select-object -expand name ) | |
foreach ($computer in $contents) | |
{ | |
if (fastping $computer) | |
{ | |
get-wmiobject -computer $computer -query "select * from win32_quickfixengineering where hotfixid like '%2982791%' OR hotfixid like '%2970228%' " | select-object csname, hotfixid, installedOn | export-csv -append -NoTypeInformation -noclobber "c:\users\mbrown\desktop\evilkbsliveshere.csv" -Encoding UTF8 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function append-listofoldfilestoafile { | |
param( | |
[int]$fileageinhours, | |
[string]$filepath | |
) | |
#require a filepath | |
if ( -not ($filepath) ) { | |
throw "give me a filepath sucker" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://support.software.dell.com/kb/119400 | |
Import-Module AppAssurePowerShellModule | |
Suspend-Snapshot –All | |
Suspend-Replication -outgoing [hostname of remote core] -all | |
Suspend-Replication -incoming [hostname of remote core] -all | |
Suspend-Vmexport –All | |
if ( $(Get-ActiveJobs –All) -like "%no jobs%" ) {echo "what!"} # "No jobs of the specified type were found on the core." note that you will have to use dotpeek on the dll returned by `Get-Module AppAssurePowerShellModule | fl path` to actually see what the hell is going on here. | |
Set-Service AppAssureCore -StartupType Disabled | |
Stop-Service AppAssureCore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://support.software.dell.com/kb/119400 | |
Import-Module AppAssurePowerShellModule | |
Sc.exe Config AppAssureCore Start= Delayed-Auto | |
Start-Service AppAssureCore | |
Resume-Snapshot –All | |
Resume-Replication -outgoing [hostname of remote core] -all | |
Resume-Replication -incoming [hostname of remote core] -all | |
Resume-Vmexport –All |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get-adusersid{ | |
#http://community.spiceworks.com/how_to/show/2776-powershell-sid-to-user-and-user-to-sid | |
param( | |
[string]$domain, | |
[string]$user | |
) | |
$objUser = New-Object System.Security.Principal.NTAccount("$domain", "$user") | |
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier]) |
OlderNewer