IT Engineer

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    I’d have to agree with Olaf. You haven’t even attempted to adapt either of the scripts for your needs?

    That’s why I have reduced the scope of this question to just a discussion, as I do not have experience in this advance Powershell scripting.

    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    Done that, I have reduced the scope of the question here to just explain to me which cmdlets and script can be developed further.

    So all is good, relax man, chill out and take it easy.

    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    I got this console prompt when testing running that command in the Windows Server 2008 R2 VMs:

     

    PS C:\> winrm quickconfig
    WinRM already is set up to receive requests on this machine.
    WinRM is not set up to allow remote access to this machine for management.
    The following changes must be made:

    Create a WinRM listener on http://* to accept WS-Man requests to any IP on this machine.
    Enable the WinRM firewall exception.

    Make these changes [y/n]?

    The problem is there are 100+ of them, and how do I enable it on all of those servers via GPO or different script?

    in reply to: Query OnPremise AD for Specific AD attributes not working? #140340
    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    Thanks all for the pointers and the assistance in this matter.

    It is working great now.

    in reply to: Query OnPremise AD for Specific AD attributes not working? #140322
    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    Cool, that’s very spot on 🙂

    So I have changed the query below, but still, no result is returned?

    Get-ADUser-Filter *-Properties *|
    Where-Object {($_.msExchRemoteRecipientType-eq4) -and
      ($_.msExchRecipientDisplayType -eq '-2147483642') -and
      ($_.msExchRecipientTypeDetails -eq '2147483648') -and
      ($_.proxyAddresses -contains "*.onmicrosoft.com*")
    }

    Is there anything that must be modified to search the proxyAddresses attribute which contains “*.onmicrosoft.com*” ?

    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    What would be the difference with the WMI method?

    Get-WmiObject -Class “Win32_QuickFixEngineering” -ComputerName $_.Name-ErrorAction Stop |
                Select-Object -Property `
                    @{Name=”ComputerName”; Expression={$Server}},
                    “Description”,
                    “HotfixID”,
                    @{Name=”InstalledOn”; Expression={([DateTime]($_.InstalledOn)).ToLocalTime()}},
                    “Error”
            “OK.”
    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    Thanks all for the suggestion.

    I need the last date of the patch applied, hence I put the key $keyValue = $regkey.GetValue(‘LastSuccessTime’).

    So I can now change that into:

    Get-HotFix -ComputerName $_.Name | Sort-Object InstalledOn | Select-Object -Property PSComputerName, Description, HotFixID, InstalledOn, InstalledBy -Last 1
    Would that be correct?
    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    Yes, @Rob code does the trick. 🙂

    @Olaf, yes that’s right.



    @Jeff
    , That’s cool, I will learn about that cmdlet.

     

    Thanks all for participating.

    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    @postanote, Cool, thanks man 🙂

    @Spietersz, how to execute that function in Visual Studio code?

    @Jon, thanks, man.

    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    I believe above code is not from a script and you have a Tab opened in ISE and the above code snippet in that session.

    You don’t need to Install the module every time, if the target node is PowerShell v3 (hope you are not using the deprecated v2) then even the Import module part is also not required as there is a module autoload feature in PowerShell from v3 onwards.

    if you haven’t heard about implicit remoting, please check it here, it will usefull for you.

    KV,

    My goal is to be able to double click the file as.Batch file or as.PS1 so I can update the Azure AD Synch quickly.

    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    OK, It seems the remoting is working great for me.

    Thanks all for the sharing and the solutions.

    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    Is this “[int]($_.Name” not exactly what Olaf was saying, about not being able to define [int]’nineteen’, except you’re trying to define [int]’PRD”, [int]’DR’, [int]’TEST’.

    $patterns = 'PROD', 'TEST', 'DR'
    $CurrentADComputerName = $null
    $NextADComputerName = $null
    
    ForEach ( $prefix in $patterns) {
        
        $CurrentADComputerName = Get-ADComputer -Filter "Name -like '$($prefix)*'" | 
            Sort-Object Name | 
            Select-Object -Expand Name | 
            Select-Object -Last 1
        Write-Host "The current AD Computername for $prefix is: $CurrentADComputerName" -BackgroundColor Blue -ForegroundColor Yellow
    
        $CurrentOULocation = (Get-ADComputer $CurrentADComputerName -Properties *).DistinguishedName
    
        $NextADComputerName = Get-ADComputer -Filter "Name -like '$($prefix)*'" |
            ForEach-Object {[int]($_.Name -replace '(?:.*?)(\d+)\Z', '$1')} |
            Measure-Object -Maximum |
            ForEach-Object {$prefix + (++$_.Maximum).ToString('000')}
        Write-Host "The next available AD Computername for $prefix is: $NextADComputerName" -BackgroundColor Blue -ForegroundColor Green
        Write-Host "Which can be deployed in OU: $CurrentOULocation `n`n" -BackgroundColor Blue -ForegroundColor White
    
    }

    OK, I have modified it like the above code, but so far I need to suppress the error with the AD object that is like the below:

    Cannot convert value “PRD23-OLD” to type “System.Int32”. Error: “Input string was not in a correct format.”
    Cannot convert value “TEST72-DEV” to type “System.Int32”. Error: “Input string was not in a correct format.”

    and how to display the OU location like: domain.com/SITE 1/Server/Production not as DN with CN ?

    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    Hi Olaf,

    $patterns = 'PRD', 'DR', 'TEST'
    
    ForEach( $prefix in $patterns) {
        Get-ADComputer -Filter "Name -like '$($prefix)*'" |
            ForEach-Object {[int]($_.Name -replace '(?:.*?)(\d+)\Z', '$1')} |
            Measure-Object -Maximum |
            ForEach-Object {$prefix + (++$_.Maximum).ToString('000')}
    }

    OK, so I have format the code like the above.
    Is it possible to ignore the non-numerical value?

    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    @neemo and @Wes,

    That is great, many thanks for the quick response and the suggestion 🙂

     

    Participant
    Topics: 21
    Replies: 20
    Points: 191
    Rank: Participant

    When I execute the below script:

    $DNSServer = “servernameOrIp”
    $Zones = @(Get-DnsServerZone -ComputerName $DNSServer)
    ForEach ($Zone in $Zones) {
    Write-Host “`n$($Zone.ZoneName)” -ForegroundColor “Green”
    $Results = $Zone | Get-DnsServerResourceRecord -ComputerName $DNSServer
    echo $Results > “$($Zone.ZoneName).txt”
    }

    I get the error:

    Get-DnsServerZone : The term ‘Get-DnsServerZone’ is not recognized as the name of a cmdlet, function, script file, or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:2 char:12
    + $Zones = @(Get-DnsServerZone -ComputerName $DNSServer)
    + ~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Get-DnsServerZone:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

     

Viewing 15 posts - 1 through 15 (of 20 total)