Quantcast
Channel: Windows PowerShell forum
Viewing all 21975 articles
Browse latest View live

PowerShell 3 update-help (proxy issues?)

$
0
0

I am running the PowerShell 3.0, as an admin, but update-help is not working. I suspect it does not know that we have an outbound proxy that requires: port, host, username, password. However WinHTTP API apps should grab this from the default credentials. I expected PS to do this.

PS C:\Windows\system32> update-help
update-help : Failed to update Help for the module(s) 'ISE, Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility, CimCmdlets, Microsoft.PowerShell.Diagnostics,
Microsoft.PowerShell.Host, Microsoft.PowerShell.Security, Microsoft.WSMan.Management, PSScheduledJob, PSWorkflow, PSWorkflowUtility, Microsoft.PowerShell.Core' with UI
culture(s) {en-US} : Unable to connect to Help content. Make sure the server is available and then try the command again.
At line:1 char:1
+ update-help
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Update-Help], Exception
    + FullyQualifiedErrorId : UnableToConnect,Microsoft.PowerShell.Commands.UpdateHelpCommand


Dr. YSG


Unexpected Token Error in Powershell

$
0
0

I am getting the error below, and below that is my script. I'm not a pro at powershell and most of this script came from someone else. In ISE, and I don't know that this matters but thought I'd bring it up, the being quote on line 5 for the email address, is colored brown, and the end quote is colored blue like the email. I actually double quoted the email address on line 5 and got pass the error, but each line with something in quotes failed with the same error. Ultimately, the script did not run after trying all in double quotes. Again sorry for being such a noob, I'm sure it's something simple I'm over looking. It seems to be quite a common error but nothing I found is working. Thanks for your help!

Error
At line:5 char:15
+  $Username = “youremail@gmail.com
+               ~~~~~~~~~~~~~~~~~~
Unexpected token 'youremail@gmail.com
$Password = “yourpassword”
$to = “yoursendtoemail@gmail.com
$subject = “Replica' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken


Script
if ((Get-VMReplication | select-string -inputobject {$_.Health} -pattern “Warning”) -like “Warning”)
 {
 $SMTPServer = “smtp.gmail.com”
$SMTPPort = “587″
 $Username = “youremail@gmail.com
$Password = “yourpassword”
$to = “yoursendtoemail@gmail.com
$subject = “Replica WARNING error on BDR1”
$message = New-Object System.Net.Mail.MailMessage
 $message.subject = $subject
$message.to.add($to)
 $message.from = $username
 $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
 $smtp.EnableSSL = $true
 $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
 $smtp.send($message)
 }
elseif ((Get-VMReplication | select-string -inputobject {$_.Health} -pattern “Critical”) -like “Critical”)
 {
 $SMTPServer = “smtp.gmail.com”
$SMTPPort = “587″
 $Username = “youremail@gmail.com
$Password = “yourpassword”
$to = “yoursendtoemail@gmail.com
$subject = “Replica CRITICAL error on BDR1”
$message = New-Object System.Net.Mail.MailMessage
 $message.subject = $subject
 $message.to.add($to)
 $message.from = $username
 $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
 $smtp.EnableSSL = $true
 $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
 $smtp.send($message)
 }

Logon Script Map network drive based on username

$
0
0

I want to map a specific network drive based on the username used to log in for example; this is what I have so far:

$net = $(New-Object -ComObject WScript.Network)
$net.MapNetworkDrive("y:", "\\wstation\c$\y",,"username","password")

But I would prefer not to pass the password in clear text or for it to be visible to users.  

Logic:

If current user = bloggs

then "run the script"

else

do nothing

Any help with this would be great


Chris Golden

Variables -SearchBase

$
0
0

Im a little lost here.  Hopefully you can see with my code what I am trying to achieve:

$Dept=@("Sales","Finance")
$OU=@("ou=Sales,ou=Finance,ou=WS,dc=ads,dc=contoso,dc=net")
#change -lt value to add more sources and destinations
for ($i=0; $i -lt 2; $i++) {

Write-Host $i

Get-ADUser -SearchBase $OU -Filter * | `
 Set-ADUser -City "XXXX" `
  -State 'XXXX' `
  -StreetAddress 'XXXXXXX' `
  -Description 'XXXX' `
  -Organization 'XXXXXXXX' `
  -Country 'XX' `
  -Department "$Dept" `
  -PostalCode XXXX `
  -PassThru


}

I have replaced the true values with X

I get this error when I run it:

Get-ADUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'SearchBase'. Specified method is not supported.
At C:\Users\XXX\Desktop\Update_Address_details.ps1:8 char:24
+ Get-ADUser -SearchBase $OU -Filter * | `
+                        ~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-ADUser], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.ActiveDirectory.Management.Commands.GetADUser

Any ideas?


Chris Golden

Get-ChildItem - Include from array not returning files

$
0
0

Config value: 

<FileTypesToDelete>*.txt,*.log,*.mf</FileTypesToDelete>

setting variable in script

[string[]]$FileTypesToDelete = @($configfile.Settings.FileTypesToDelete)
#$FileTypesToDelete =$configfile.Settings.FileTypesToDelete


i've tried both the above ways to set the $FileTypesToDelete var and the code where I'm using this:

$logFiles = Get-Childitem $dir"\*" -Include $FileTypesToDelete,$liveSiteLogs -Exclude $configfile.Settings.FileExclusions | Where {$_.LastWriteTime -le "$LastWrite"}

when I run this logic i get this error:

Get-ChildItem : Cannot convert 'System.String[]' to the type 'System.String' required by parameter 'Include'. Specified method is not supported.
At C:\Users\pmcma\Documents\Projects\Replace FileCleaner with PowerShell Script\TestSnippets.ps1:53 char:45+ $logFiles = Get-Childitem $dir"\*" -Include $FileTypesToDelete,$liveSiteLogs -Ex ...+                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.GetChildItemCommand

but if I change this around and hard-code the values to be delete the code works fine:

$logFiles = Get-Childitem $dir"\*" -Include "*.txt","*.log",".mf", $liveSiteLogs -Exclude $fileExclusions | Where {$_.LastWriteTime -le "$LastWrite"}

but I want to read these values in from a config file so can anyone enlighten me as to why my top array is failing?

Thanks in advance

Run code extracted from text

$
0
0

Is it possible to extract and run PowerShell code out of a text file without creating a new file?

I have some files (not .ps1 files) containing lines of PowerShell intermixed with lines of other text.  I have a function that successfully extracts the PowerShell into a string variable, $code.  In testing I can make it as simple as:

$code = get-content .\onlycode.txt

I want to then run the lines I extracted, but I cannot for the life of me figure out how if there is more than a single line.  I've tried: 

  • & $code --> This tells me [contents of $code] is not recognized as a cmdlet, function, etc.
  • & {$code} --> This just parrots back $code as text including newlines
  • Invoke-command -scriptblock {$code} --> This just parrots back $code as text including newlines
  • Invoke-command -scriptblock {& {$code}} --> This just parrots back $code as text without newlines
  • Invoke-expression $code --> "Cannot convert 'system.object' to the type 'system.string'"
  • Invoke-expression "& {$code}" --> "missing closing '}' in statement block" ??

What am I doing wrong?  Is this not possible? 

Thanks.

Windows Update PowerShell Script

$
0
0

Hi All 

I have this Windows update Powershell script below which works pretty much fine. I would like to add a csv file that will contain multiple Serves and do the updates on them. The issue is getting the script to get the machines name from the CSV file and and update it based on the CSV file. Can anyone assist on this matter.

$UpdateSession = New-Object -Com Microsoft.Update.Session
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
 
Write-Host("Searching for applicable updates...") -Fore Green
 
$SearchResult = $UpdateSearcher.Search("IsInstalled=0 and Type='Software'")
 
Write-Host("")
Write-Host("List of applicable items on the machine:") -Fore Green
For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
    $Update = $SearchResult.Updates.Item($X)
    Write-Host( ($X + 1).ToString() + "&gt; " + $Update.Title)
}
 
If ($SearchResult.Updates.Count -eq 0) {
    Write-Host("There are no applicable updates.")
    Exit
}
 
#Write-Host("")
#Write-Host("Creating collection of updates to download:") -Fore Green
 
$UpdatesToDownload = New-Object -Com Microsoft.Update.UpdateColl
 
For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
    $Update = $SearchResult.Updates.Item($X)
    #Write-Host( ($X + 1).ToString() + "&gt; Adding: " + $Update.Title)
    $Null = $UpdatesToDownload.Add($Update)
}
 
Write-Host("")
Write-Host("Downloading Updates...")  -Fore Green
 
$Downloader = $UpdateSession.CreateUpdateDownloader()
$Downloader.Updates = $UpdatesToDownload
$Null = $Downloader.Download()
 
#Write-Host("")
#Write-Host("List of Downloaded Updates...") -Fore Green
 
$UpdatesToInstall = New-Object -Com Microsoft.Update.UpdateColl
 
For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
    $Update = $SearchResult.Updates.Item($X)
    If ($Update.IsDownloaded) {
        #Write-Host( ($X + 1).ToString() + "&gt; " + $Update.Title)
        $Null = $UpdatesToInstall.Add($Update)        
    }
}
 
$Install = [System.String]$Args[0]
$Reboot  = [System.String]$Args[1]
 
If (!$Install){
    $Install = Read-Host("Would you like to install these updates now? (Y/N)")
}
 
If ($Install.ToUpper() -eq "Y" -or $Install.ToUpper() -eq "YES"){
    Write-Host("")
    Write-Host("Installing Updates...") -Fore Green
 
    $Installer = $UpdateSession.CreateUpdateInstaller()
    $Installer.Updates = $UpdatesToInstall
 
    $InstallationResult = $Installer.Install()
 
    Write-Host("")
    Write-Host("List of Updates Installed with Results:") -Fore Green
 
    For ($X = 0; $X -lt $UpdatesToInstall.Count; $X++){
        Write-Host($UpdatesToInstall.Item($X).Title + ": " + $InstallationResult.GetUpdateResult($X).ResultCode)
    }
 
    Write-Host("")
    Write-Host("Installation Result: " + $InstallationResult.ResultCode)
    Write-Host("    Reboot Required: " + $InstallationResult.RebootRequired)
 
    If ($InstallationResult.RebootRequire -eq $True){
        If (!$Reboot){
            $Reboot = Read-Host("Would you like to install these updates now? (Y/N)")
        }
 
        If ($Reboot.ToUpper() -eq "Y" -or $Reboot.ToUpper() -eq "YES"){
            Write-Host("")
            Write-Host("Rebooting...") -Fore Green
            (Get-WMIObject -Class Win32_OperatingSystem).Reboot()
        }
    }
}

Install Office Add-on pre-determine 64x or 32x

$
0
0

Good afternoon all,

I am looking to roll out a Microsoft Outlook add-on through group policy, there are two versions of the client, x64 & x32.

Unfortunately my estate houses a number of 32 bit & 64 bit Office installs, and the add-on is dependant on the version of office.

I require a script to carry out the following

1. Check if the remote machine is running x64 or x32 office

2. Install the relevant add-on depending on the outcome in step 1.

Any help would be greatly appreciated.

Thanks,

Hassan.


Convert a "System.String" to a "System.Security.SecureString" in the PS code

$
0
0

I want to add a "System.Security.SecureString" to my Powershell ADDS command.

-SafeModeAdministratorPassword<SecureString>

This is what I have now:

Import-Module ADDSDeployment
Install-ADDSForest '
...
-SafeModeAdministratorPassword "password" `
...

which is a "System.String".

I would like to convert a "System.String" to a "System.Security.SecureString" in the PS code.


PowerShell script error when running it in a MDT task sequence

$
0
0

When I run the following script on a computer it works perfectly but when I run the script as part of a MDT task sequence I get an error.

The code is for automatically adding the computer being imaged to a security group for Direct Access.  I have tried running it with and without a domain admin account. 

Any help would be appreciated.

Thanks,

Andy

Code:

 

$ComputerName = gc env:computername
$GroupPath = "LDAP://CN=DirectAccessComputers,OU=Security Groups,DC=xxx,DC=xx,DC=xx,DC=xx"
$computerPath = "LDAP://CN=$ComputerName,OU=NewComputers,DC=xxx,DC=xx,DC=xx,DC=xx" 

$Group =[ADSI]"$GroupPath"

$Group.Add("$computerPath")
$Group.SetInfo()

Error Messages:

The following exception occurred while retrieving member "Add": "The specified domain either does not exist or could not be contacted.
"TaskSequencePSHost03/24/2015 2:09:24 PM0 (0x0000)
At \\AOTWDS01V\DeploymentShare$\Scripts\dagroup.ps1:7 char:1
+ $Group.Add("$computerPath")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~TaskSequencePSHost03/24/2015 2:09:24 PM0 (0x0000)
NotSpecified: (:) [], ExtendedTypeSystemException TaskSequencePSHost03/24/2015 2:09:24 PM0 (0x0000)
The following exception occurred while retrieving member "SetInfo": "The specified domain either does not exist or could not be contacted.
"TaskSequencePSHost03/24/2015 2:09:24 PM0 (0x0000)
At \\AOTWDS01V\DeploymentShare$\Scripts\dagroup.ps1:8 char:1
+ $Group.SetInfo()
+ ~~~~~~~~~~~~~~~~TaskSequencePSHost03/24/2015 2:09:24 PM0 (0x0000)
NotSpecified: (:) [], ExtendedTypeSystemException TaskSequencePSHost03/24/2015 2:09:24 PM0 (0x0000)
TSHOST: Script completed with return code 0 TaskSequencePSHost03/24/2015 2:09:24 PM0 (0x0000)

Groups and permissions

$
0
0

I'm preparing a script where some local groups need to be created then domain groups added to them. Also it'll create some folder structure and assing my local groups with the right permissions. I thought that rather than hardcodding all that it would be better to make it more general so if groups need to be changed or folder structure modified it can be easily done. Hence I decided to use it as a good opportunity to learn to work with functions to extend my beginner's PS skills.

I started with creating text files with what will be needed later. So I have folders.txt, LocalG.txt and DomainG_A.txt DomainG_B.txt all put in variables

###############################

$folders = Get-Content .\folders.txt

$LocalG = Get-Content .\LocalG.txt

$DomainG_A = Get-Content .\DomainG_A.txt

$DomainG_B = Get-Content .\DomainG_B.txt

#######  Functions   #################

# Test if folders exist and if not create them

Function TestFolders ($folders){

              foreach($folder in $folders){

                       if((Test-Path $folder) -eq $False){

                            New-Item -Path $folder -ItemType Directory -Force

                       }

                }

}

# Remove all ACLs from existing folder structure in case it's incorrect

Function RemoveACL ($folder) {

$acl = Get-Acl $folder

foreach($access in $acl.Access){

         $acl.SetAclAccessRuleProtection($True, $True)

         $acl.RemoveAccessRuleAll($access)

}

Set-Acl $folder $acl

}

# Create Local Groups

Function AddLocalGroups ($Groups){

foreach ($group in $Groups){

         $cn = [ADSI]("WinNT://$env:computername")

         $gp = $cn.Create("Group", "$group")

         $gp.setInfo()

}

}

# Here I would like adding domain groups A and B to some of my local groups

Function AddTo_A_Group ($AGroups){

foreach($gp in $AGroups){

           $gr = $gp.Replace('\','/')  # as we will likely see domain\group format in the text file

            $objGroup = [ADSI]"WinNT://$gr"

            $objGroupA1 = [ADSI]("WinNT://Test Group 1 A")

            $objGroupA1.PSBase.Invoke('Add',$objGroup.PSBase.Path)

            $objGroupA2 = [ADSI]("WinNT://Test Group 2 A")

            $objGroupA2.PSBase.Invoke('Add',$objGroup.PSBase.Path)

}

}



Function AddTo_B_Group ($BGroups){

foreach($gp in $BGroups){

              $gr = $gp.Replace('\','/')

              $objGroup = [ADSI]"WinNT://$gr"

              $objGroupB1 = [ADSI]("WinNT://Test group 1 B")

              $objGroupB1.PSBase.Invoke('Add',$objGroup.PSBase.Path)

              $objGroupB2 = [ADSI]("WinNT://Test group 2 B")

              $objGroupB2.PSBase.Invoke('Add',$objGroup.PSBase.Path)

}

}  # surely this can be done better

# To add a group and assign e.g. read and execute permissions

Function ModifyACL($folder,$group){

$acl = Get-Acl $folder

$rule = New-Object System.Security.AccessControl.FileSystemRule -ArgumentList @(

               $group.Name,

               "ReadAndExecute",

               "ContainerInherit, ObjectInherit",

               "None",

               "Allow"

               )

$acl.AddAccessRule($rule)

Set-ACL $folder $acl

}

##################################

AddLocalGroups($LocalG)            # create local groups based on the contents of LocalG.txt

AddTo_A_Group($DomainG_A)     # add A domain groups to Local groups with A in their name

AddTo_B_Group($DomainG_B)     # add B domain groups to Local groups with B in their name

foreach ($folder in $folders){

           TestFolders($folder)          # test if folders exists and create as needed

           RemoveACL($folder)          # remove all current permissions

           foreach($group in $LocalG){

                   if($group -match "A"){          # for all groups with A in their name

                            ModifyACL($folder, $group)      # add group and give it R&E permissions

                    }

            }

}

Running the above Local groups get created and this is as far as it gets :)

When the script gets to AddTo_A_Group function it throws an exception calling Invoke with 2 arguments: Unknown name(0x80020006 (Disp_E_UNKNOWNNAME) on my $objGroupA.PSBase.Invoke('Add',$objGroup.PSBase.Path)

Some help would be much appreciated.

   


yaro

Be our next Spring PowerShell Guru!

$
0
0



In the northern hemisphere at least, Spring is here! (apparently)

And at TechNet Wiki, we're hoping you're all hatching new ideas for this month's TechNet Guru competition!

We're looking for more shoots and leaves of wisdom to sprout forth from the great tree of MSDN/TechNet life.

We're also hoping some of our old Guru winners will be coming back out of hibernation and flexing their grey matter!

So, pick up your pen and MARCH into TechNet History! This could truly be the start of something BEAUTIFUL!

What delightful new arrival will YOU be bringing into this world?

All you have to do is add an article to TechNet Wiki from your own specialist field. Something that fits into one of the categories listed on the submissions page. Copy in your own blog posts, a forum solution, a white paper, or just something you had to solve for your own day's work today.

Drop us some nifty knowledge, or superb snippets, and become MICROSOFT TECHNOLOGY GURU OF THE MONTH!

This is an official Microsoft TechNet recognition, where people such as yourselves can truly get noticed!

HOW TO WIN

1) Please copy over your Microsoft technical solutions and revelations toTechNet Wiki.

2) Add a link to it on THIS WIKI COMPETITION PAGE (so we know you've contributed)

3) Every month, we will highlight your contributions, and select a "Guru of the Month" in each technology.

If you win, we will sing your praises in blogs and forums, similar to the weekly contributor awards. Once "on our radar" and making your mark, you will probably be interviewed for your greatness, and maybe eventually even invited into other inner TechNet/MSDN circles!

Winning this award in your favoured technology will help us learn the active members in each community.

Feel free to ask any questions below.

More about TechNet Guru Awards

Thanks in advance!
Pete Laker



#PEJL
Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over toTechNet Wiki, for future generations to benefit from! You'll never get archived again, and you could win weekly awards!

Have you got what it takes o become this month's TechNet Technical Guru? Join a long list of well known community big hitters, show your knowledge and prowess in your favoured technologies!


Find hostnames of slaved drives

$
0
0

I have about 200+ archived HDD's that I need to find the hostnames for, and I was wondering if someone can tell me it there is a good way to do this through Powershell, or if there is a different way of doing it that would be better, like creating a CMD batch script or something?  I don't know any other programming/scripting languages like Python, etc, so I would like to stick with either Powershell or command line if possible.  I will be slaving them up to another PC to find this, and some of the drives will be on XP, some will be on Windows 7.

Thanks in advance.

How to add hash table values to SQL Table using Powershell

$
0
0

Hi,

I have sharepoint list with four(column1, column2, column3,column4)columns.I am reading the list column values and adding to hashtable. Now I want to add values from hastable to SQL table with four(column1, column2, colum3,column4)columns using powershell.

I have written the following script for single column but I would like to know how to add values for multiple columns.



            if(($key -eq "Column1") )
            {

               $SqlQuery = "INSERT INTO [TableName] ([Column1]) VALUES ('" + $HashTable.Item($key) +"')"
               #Set new object to connect to sql database
               $connection = new-object system.data.sqlclient.sqlconnection
               $Connection.ConnectionString ="server=SQLServerName;database=SQLDBName;Integrated Security = True;"
          $connection #List connection information 
               $connection.open() #Open Connection
             $Cmd = New-Object System.Data.SqlClient.SqlCommand
             $Cmd.CommandText = $SqlQuery
               $Cmd.Connection = $connection
              $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
              $SqlAdapter.SelectCommand = $SqlCmd
              $DataSet = New-Object System.Data.DataSet
              $SqlAdapter.Fill($DataSet)
              $DataSet.Tables[0]
              $connection.Close()

Can anybody please help me out to accomplish the task? Any help would be greatly appreciated.

Thank you advance.

                                        

AA.

Signed Powershell Script

$
0
0

Hello,

I have trouble with self signed Powershell scripts.

I've created a CodeSign Certificate from the internal CA in my Domain.

After that I've used this Certificate to sign PS scripts.

When I call these scripts in a running shell I get this message:

Do you want to run software from this untrusted publisher?
File z:\Applications\Scripts\HelloWorld.ps1 is published by CN=Administrator, CN=Users, DC=contoso, DC=com
and is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run  [D] Do not run  [R] Run once  [A] Always run  [?] Help (default is "D")

I've imported this certificate to the Trusted Root Store of the Server and the current User Account.

So I can't explain why this is not working!

Has anyone a hint for me?

Thanks!


Adding invalid hexadecimal values to XML

$
0
0

Hi guys,

I have some code that needs to create an XML Text Node with a string value.

$vArray = "*/New _test/","*/test/ssh?Name=.&amp;"

for($i = 0; $i -lt $vArray.length; $i++)
{
    $xdoc."data_Employ"."conf".AppendChild($xmlPort.CreateElement("FilConf"))
$xdoc."data_Employ"."conf"."FilConf".AppendChild($xmlPort.CreateElement(FilConf[$i]))
}

When I run this I get "powershell hexadecimal value 0x2A is an invalid character" and many more. 

How do I resolve this? I need these characters in the XML doc. 

Active Directory User information

$
0
0

Hi there,

I'm new to PowerShell and would like to get assistance on the following requirements: Get the list of all Active Directory groups, their associated members along with information such as windows login, name, and manager name.

Any assistance would be much appreciated.

Thank you

Code Singed Certificates not working

$
0
0

Hello Everyone,

 

I have a code signed certificate for all my PowerShell scripts when I try and run any of my PowerShell scripts I get

 

Do you want to run software from this untrusted publisher?

File .\outlook_sig_alpha.ps1 is published by CN="Joseph, John",

OU=XXXX, OU=XXX, DC=XXXX, DC=XXXX and is not trusted on your system. Only run scripts

from trusted publishers.

[V] Never run  [D] Do not run  [R] Run once [A] Always run  [?] Help (default is "D"):

 

When I run Get-AuthenticodeSignature on the file I get:

 

PS C:\> Get-AuthenticodeSignature .\outlook_sig.ps1 | format-list

 

 

SignerCertificate      : [Subject]

                          CN="Joseph, John", OU=Information Systems, OU=xxxx, DC=xxxx, DC=xxxx

 

                        [Issuer]

                          CN=ServerName-CA, DC=Domain, DC=Name

 

                        [Serial Number]

                          108EB4280001000003CE

 

                        [Not Before]

                          12/15/2014 11:00:12 AM

 

                        [Not After]

                          12/15/2015 11:00:12 AM

 

                        [Thumbprint]

                          D73767D0AE21F235C3C4E579AE2EB31A3C5AB027

 

TimeStamperCertificate : [Subject]

                          CN=GlobalSign TSA for MS Authenticode - G2, O=GMO GlobalSign Pte Ltd, C=SG

 

                        [Issuer]

                          CN=GlobalSign Timestamping CA - G2, O=GlobalSign nv-sa, C=BE

 

                        [Serial Number]

                          112106A081D33FD87AE5824CC16B52094E03

 

                        [Not Before]

                          2/2/2015 7:00:00 PM

 

                        [Not After]

                          3/2/2026 7:00:00 PM

 

                        [Thumbprint]

                          B36308B4D4CDED4FCFBD66B955FAE3BFB12C29E6

 

Status                : Valid

StatusMessage          : Signature verified.

Path                  : C:\outlook_sig.ps1

 

I checked and verified that the certificate is installed on the local computer account and the Certificate is listed under Trusted Publisher.  We have Powershell version 2 and version 4 running in our enviroment both 32 and 64 bit OS.

PS C:\> Get-ExecutionPolicy
AllSigned

Any help would be appreciated.

Thank you,

John Joseph

formating results from Get-qadgroup and get-qadgroupmember

$
0
0

Hello ,


I am stuck trying to build a script that searches our AD and extracts some specific information about groups. 

I have the search part working and both get-qadgroup and get-qadgroupmembers gives me the results I require , but don't know how to get the data into the output format I require.

$search = Read-Host 'please enter a search value'
$groups = get-qadgroup -SizeLimit 0 | Where-Object {$_.notes -Match "$search"}

this is my search and it creates my list of groups ok. From that I would like to extract some data using get-qadgroup ( name,type,description,notes ) and then also append the data with the membership of the groups using get-qadgroupmember (name)

I've tried using a basic foreach loop and piping the results to a txt file but cant get a format  that works. What is the best way to gather the results and export to a file so that the results looks something like this - ( ideally something that can be imported to excel ) 

groupname, grouptype, groupdescription, groupnotes, groupmembers

thanks

Chris

Powershell GUI Popup Box - Line Break

$
0
0

Building a GUI (IT Helpdesk Tool) to do daily tasks. One part is to grab computer information.

I have the drop down displaying a list of all the computers.  On the "Get Computer Info" Button - it does a WMI query to get all of the computer info that I have requested.  Question I have it is on the message box that displays the info - how do I line break to a new line?

I have a little work to do on what information I am pulling, but want to get the formatting working correctly first.

In short - how do I line break on a MessageBox?

Thanks

	$buttonComputerInfo_Click = {
		$computer = $dropdown2.Text
			if ([string]::IsNullOrEmpty($computer) -eq $false){
                [string]$computer
				$colItems = get-wmiobject -class "Win32_ComputerSystem" -namespace "root\CIMV2" -computername $computer

				foreach ($objItem in $colItems){
					$displayGB = [math]::round($objItem.TotalPhysicalMemory/1024/1024/1024, 0)
					#write-host "Total Physical Memory: " $displayGB "GB"
					#write-host "Model: " $objItem.Model
				}

				$colItems2 = get-wmiobject -class "Win32_Processor" -namespace "root\CIMV2" -computername $computer
				foreach ($objItem in $colItems2){
				#write-host "System Name: " $objItem.SystemName
				}
				[System.Windows.Forms.MessageBox]::Show("System Name:  $Computer Memory: $displayGB GB Model: $objItem.Model")
			}
			else {
            	[System.Windows.Forms.MessageBox]::Show("The Computer Name field is empty.  Select a computer from the drop down.")
           }
    }

Viewing all 21975 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>