Git Product home page Git Product logo

poshinternals's Introduction

PoshInternals

A pure script-based PowerShell module that provides deep system analysis and configuration.

poshinternals's People

Contributors

adamdriscoll avatar brutalsimplicity avatar codespare avatar sunnyc7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poshinternals's Issues

Copypaste detected

Hey, dude! What are crap with your Pinvoke.cs? It's fully filled by copypaste code. And if you don't know all sysinternals tools (except GUI which requires additional drivers as Process Monitor and Process Explorer are) can be implemented without CSharp code, only PowerShell.

Start-Process Clobber

When installing from Powershell Gallery, the module clobbers with the existing Powershell command "Start-Process", and so the install errors out. Looking at your code, I don't see any function or command called "Start-Process" that differs from the standard Powershell one.

Start-RemoteProcess as `nt authority\system`

Hi @adamdriscoll,
I'm trying to get nt authority\system processes working over PowerShell remoting. and I came across PoshExec.ps1. It looks to me that Start-RemoteProcess doesn't currently support starting a process as nt authority\system. Is that correct? If so, do you have a general idea of what would be involved to get that working? I'm just trying to get a sense of the scope of that work so I can figure out whether this is a good way to solve my problem.

Thanks for your help,

Alex

PowerShell With VS 2017

Hi All,
I Created a new PowerShell Script project. I'm Getting the error "Attaching the PowerShell Debug Engine debugger to process '{[']} on machine failed." When trying to execute an Empty PowerShell. Any Idea how to fix this?

Get-LogonSession overflow on x64

PS C:\>get-logonsession
Cannot convert value "1060472059184" to type "System.Int32". Error: "Arithmetic operation resulted in an overflow."
At C:\Program Files\WindowsPowerShell\Modules\poshinternals\ListUsers.ps1:23 char:5
+                 $currentSession = [int]$SessionInfoPtr
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastTargetInvocationExceptionop_Explicit

Cannot convert null to type "System.IntPtr".
At C:\Program Files\WindowsPowerShell\Modules\poshinternals\ListUsers.ps1:28 char:6
+                     $si = ConvertTo-Object ([System.IntPtr]$currentSession) ([PoshInternals.WTS ...
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : nullToObjectInvalidCast

Close desktop

Hello,
Running into a problem--but it could also just be my limited understanding of these functions. Anyway, I am trying to close (delete) the desktop after using 'New-Desktop' . I have tried numerous different things, but to no avail... Get-Desktop continues to list the created desktop. I even tried this (completely built off your work):

function Close-Desktop
{
    [CmdletBinding()]
    param(
        [Parameter(Mandatory, ValueFromPipeLine=$true, ParameterSetName="Desktop")]
        [PSObject]$Desktop,
        [Parameter(Mandatory, ValueFromPipeLine=$true, ParameterSetName="Name", Position=0)]
        [string]$Name
    )

    Process
    {
        if ($Desktop -eq $null)
        {
            $Desktop = Get-Desktop -Name $Name
        }

        if ($Desktop -eq $null)
        {
            Write-Error "Failed to find desktop"
            return
        }

        if (-not [PoshInternals.User32]::CloseDesktop($Desktop.Handle))
        {
            throw (New-Object System.ComponentModel.Win32Exception)
        }
    }
}

Any ideas on how to destroy the desktop?

Freeze on Enumerating File Handle Names

Hey man, awesome library, thanks for the effort.

I was trying to use your library in a small utility for renaming directories that have been locked by Visual Studio (not sure why/how this happens), and I ran into an issue when enumerating the handle names for file types. Basically the program would hang when trying to get the handle's property Name. Best I can tell is that it happens on the NtQueryObject call after checking the GrantedAccess value. After some investigation I found that the offending value was 0x1A019F. After adding it to the check it worked like a charm!

Not sure if you are aware what this particular access value represents (from winnt.h it looks like the set bits are WRITE_OWNER, DELETE, FILE_READ_EA, FILE_READ_DATA, and FILE_READ_ATTRIBUTES), but thought I might bring it to your attention. You'll recognize the updated piece of code below.

Again, thanks. This was very useful.

  // Query the object name
  if (_typeStr != null && GrantedAccess != 0x0012019f && GrantedAccess != 0x00120189 && GrantedAccess != 0x120089 && GrantedAccess != 0x1A019F) // dont query some objects that could get stuck
  {
    int length;
    NtDll.NtQueryObject(handleDuplicate, OBJECT_INFORMATION_CLASS.ObjectNameInformation, IntPtr.Zero, 0, out length);
    IntPtr ptr = IntPtr.Zero;
    try
    {
      ptr = Marshal.AllocHGlobal(length);
      if (NtDll.NtQueryObject(handleDuplicate, OBJECT_INFORMATION_CLASS.ObjectNameInformation, ptr, length, out length) != NtStatus.Success)
        return;
      _name = Marshal.PtrToStringUni((IntPtr)((long)ptr + 2 * IntPtr.Size));
      if (_typeStr == "File" || _typeStr == "Directory")
      {
        _name = GetRegularFileNameFromDevice(_name);
      }
    }
    finally
    {
      Marshal.FreeHGlobal(ptr);
    }
  }
}

PowerShell project

Hi All,
I Created a new PowerShell Script project. I'm Getting the error "Attaching the PowerShell Debug Engine debugger to process '{[']} on machine failed." When trying to execute an Empty PowerShell. Any Idea how to fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.