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[]]$Address = $(1..20 | %{"192.168.1.$_"}), | |
[int]$Threads = 5 | |
) | |
write-host "Distributing addresses around jobs" | |
$JobAddresses = @{} | |
$CurJob = 0 | |
$CurAddress = 0 | |
while ($CurAddress -lt $Address.count) |
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
cls | |
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition | |
$folderLocation = [System.IO.Path]::Combine($scriptPath, "PowerShellMultiThreading_SimpleExample") | |
if (Test-Path $folderLocation) | |
{ | |
Remove-Item $folderLocation -Recurse -Force | |
} | |
New-Item -Path $folderLocation -ItemType directory -Force > $null | |
# This script block will download a file from the web and create a local version |
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
(Get-WmiObject -ComputerName . -Class Win32_Printer -Filter "Name='PRINTERNAME'").SetDefaultPrinter() | |
#Import-Module ActiveDirectory | |
Invoke-Command {pnputil.exe -a "d:\Downloads\upd-pcl6-x64-6.3.0.21178\hpcu190u.inf"} | |
Add-PrinterDriver -Name "HP Universal Printing PCL 6" | |
Get-PrinterDriver | |
Add-PrinterPort -Name "IP_10.64.128.157" -PrinterHostAddress "10.64.128.157" | |
Start-Sleep 10 | |
Add-Printer -Name "HP M725" -PortName IP_10.64.128.157 -DriverName "HP Universal Printing PCL 6" |
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
write-Host "*******Decrapifying Windows 10...*******" | |
write-Host "***Removing App Packages...***" | |
#I recommend running this script on a fresh install, though it should work fine anyways. Should ;) | |
#This part removes all the apps. By default, it removes every except the calculator and the store. To remove all apps, comment out this part... | |
Get-AppxPackage -AllUsers | where-object {$_.name -notlike "*Microsoft.WindowsStore*"} | where-object {$_.name -notlike "*Microsoft.WindowsCalculator*"} | Remove-AppxPackage | |
Get-AppxProvisionedPackage -online | where-object {$_.packagename -notlike "*Microsoft.WindowsStore*"} | where-object {$_.packagename -notlike "*Microsoft.WindowsCalculator*"} | Remove-AppxProvisionedPackage -online |
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 Enable-Privilege { | |
param($Privilege) | |
$Definition = @' | |
using System; | |
using System.Runtime.InteropServices; | |
public class AdjPriv { | |
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)] | |
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, | |
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr rele); | |
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)] |
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
sc config storsvc type= own | |
rem ACP User Service | |
sc config amdacpusrsvc start= disabled | |
rem AdaptiveSleepService | |
sc config AdaptiveSleepService start= disabled | |
rem Adobe Flash Player Update Service | |
sc config AdobeFlashPlayerUpdateSvc start= disabled |
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
$Path = "C:\123\" # Путь к корневому каталогу с подкаталогами сканирования, которые нельзя удалять | |
$Dirs = Get-ChildItem -Path $Path # Занесение списка неудаляемых каталогов в массив для дальнейшей обработки | |
ForEach ($Dir in $Dirs) {$SubDirs = Get-ChildItem $Dir.PSPath | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue} # Удаление содержимого неудаляемых каталогов методом перебора всех каталогов из массива |
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
#defrag | |
Optimize-Volume -DriveLetter C -CimSession ***pc_name*** -Defrag -Verbose | |
#set gerial number | |
get-ciminstance -classname win32_bios -computername ИМЯ_ПК | format-list serialnumber | |
#get print queue | |
Get-WMIObject -ComputerName Win32_PerfFormattedData_Spooler_PrintQueue | Select Name, @{Expression={$_.jobs};Label="CurrentJobs"}, TotalJobsPrinted, JobErrors |
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
# Capturing a screenshot | |
Param( | |
[Parameter(Mandatory = $true)][string]$Path | |
) | |
$FileName = "$env:COMPUTERNAME - $(get-date -f yyyy-MM-dd_HHmmss).bmp" | |
$File = "$Path\$FileName" | |
Add-Type -AssemblyName System.Windows.Forms | |
Add-type -AssemblyName System.Drawing | |
# Gather Screen resolution information | |
$Screen = [System.Windows.Forms.SystemInformation]::VirtualScreen |
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
<# | |
GeneratePrintJobAccountingReports.ps1 | |
ver. 2014-09-26-01 | |
This script reads event log ID 307 and ID 805 from the log "Applications and Services Logs > Microsoft > Windows > PrintService" | |
from the specified server and for the specified time period and then calculates print job and total page count data from these | |
event log entries. | |
It then writes the output to two .CSV files, one showing by-print job data and the other showing by-user print job data. |
OlderNewer