none
Query for AD Computer Attribute RRS feed

  • Question

  • i would like to access an ad computer attribute from client (windows 7) without using the module active directory as i can't install it on every client. So i can write a script to pull new name for a computer, rename it and restart client.

    Would this be possible.

    the easiest way, get-adcomputer needs the module. Maybe some kind of ldap query?

    • Moved by Bill_Stewart Wednesday, December 12, 2018 6:33 PM This is not "scripts on demand"
    Friday, August 17, 2018 5:45 PM

All replies

  • You can look in the Gallery here for scripts that can get computer info without the AD module.


    \_(ツ)_/

    Friday, August 17, 2018 5:59 PM
  • What about something like this?

    ##*=========================================================
    ## Local Computer
    ##*=========================================================
    $LOCALCOMPUTER = $env:computername
    $LOCALOS = Get-WmiObject -Computer $LOCALCOMPUTER -Class Win32_OperatingSystem
    IF($LOCALOS.caption -like '*Windows 7*')
    {
        # Do something here
    }
    IF($LOCALOS.caption -like '*Windows 10*')
    {
        # Do something here
    }

    # To find all available properties for the local computer, pipe the variable out to Get-Member (Alias "GM")
    $LOCALOS | GM

    ##*=========================================================
    ## Remote Computer
    ##*=========================================================
    $REMOTECOMPUTER = ComputerName01
    $REMOTEOS = Get-WmiObject -Computer $REMOTECOMPUTER -Class Win32_OperatingSystem
    IF($REMOTEOS.caption -like '*Windows 7*')
    {
        # Do something here
    }
    IF($REMOTEOS.caption -like '*Windows 10*')
    {
        # Do something here
    }
    # To find all available properties for the remote computer, pipe the variable out to Get-Member (Alias "GM")
    $REMOTEOS | GM
    Wednesday, August 22, 2018 1:30 PM
  • To rename a computer just use the CmdLet:

    help Rename-Computer -online


    \_(ツ)_/

    Wednesday, August 22, 2018 7:12 PM
  • If you the apropriate permission, I'd suggest you use Import-Session cmdlet with -Module parameter. For example

    $session = New-PSSession -ComputerName nameOfDC

    Import-PSSession $session -Module ActiveDirectory


    Wednesday, August 22, 2018 8:30 PM
  • You do not need AD to rename a computer.  Just use the built-in CmdLet. It can rename and move a computer in AD.


    \_(ツ)_/

    Wednesday, August 22, 2018 8:39 PM