Powershell Test-Path of HKEY_USERS

Hello Folks,
I'm attempting to write a script that will update a non logged in users NTUSER.dat registry setting.
I load the hive with: REG load "hku\temp" c:\users\${username}\NTUSER.dat.  That occurs successfully, but when I attempt to do a test-path for a setting, that I know is there, it always returns false. For example:
Test-Path "hku\temp\Software\Microsoft\Office"
In fact, I do a test-path on my current HKU setting, that I copied and pasted from registry editor copy key name, and that as well says false. 
Test-Path "HKEY_USERS\SID#\Software\Microsoft\Silverlight"
Can someone please provide some guidance?  Thanks in advance!!

Hello Folks,
I'm attempting to write a script that will update a non logged in users NTUSER.dat registry setting.
I load the hive with: REG load "hku\temp" c:\users\${username}\NTUSER.dat.  That occurs successfully, but when I attempt to do a test-path for a setting, that I know is there, it always returns false. For example:
Test-Path "hku\temp\Software\Microsoft\Office"
In fact, I do a test-path on my current HKU setting, that I copied and pasted from registry editor copy key name, and that as well says false. 
Test-Path "HKEY_USERS\SID#\Software\Microsoft\Silverlight"
Can someone please provide some guidance?  Thanks in advance!!
PowerShell only sees the HKCU and HKLM hives. You cannot use Test-Path on other hives.
HELP is your friend.  You should learn to use it first:
Example:
PS C:\scripts> help registry
PROVIDER NAME
    Registry
DRIVES
    HKLM:, HKCU:
SYNOPSIS
    Provides access to the system registry keys and values from Windows PowerShell.
¯\_(ツ)_/¯

Similar Messages

  • Powershell - Test-Path if a file exists within a folder

    Hey Guys,
    I'm unable to get this to work correctly. I'm trying to see which folders have a file within them with the word "preview".  If it does, then tell me it exists, if not, then it doesn't exist.
    What am I missing?!? Ugh :(
    Here is my code
    $rootpath = "T:\Path1\Path2\*"
    foreach ($f in Get-ChildItem $rootpath)
    foreach ($i in Get-ChildItem $f)
    if (Test-Path $i -include *preview*.jpg)
    echo($i.name + " Preview Exists")
    else
    echo($i.name + " ***PREVIEW MISSING***")

    this script is only 1/2 working.
    I tested it with "t:\path1\path2\folder1\subfolder1, subfolder2, subfolder3 where preview1.jpg is n subfolder1"
    But, "t:\path1\path2\folder2\subfolder1\preview2.jpg is ignored
    foreach ($i in (Get-ChildItem $f |? {$_.psiscontainer))  should be
    foreach ($i in (Get-ChildItem $f |? {$_.psiscontainer}))
    $rootpath = "T:\Path1\Path2\*"
    $results = @()
    foreach ($f in Get-ChildItem $rootpath)
     foreach ($i in (Get-ChildItem $f |? {$_.psiscontainer))
     $result = "" | select File,PreviewStatus
     $result.file = $i.fullname
      if (Test-Path  ($i.fullname + "\*preview*.jpg"))
       echo($i.name + "           Preview Exists")
       $result.PreviewStatus = "Preview Exists"
      else
       echo($i.name + " ***PREVIEW MISSING***")
       $result.previewstatus = "Preview Missing"
    $results += $result
    $results | export-csv Preview_Status.csv -notype
    jon

  • SQL Server 2012 Import-Module 'sqlps' breaks the "Test-Path" PowerShell cmdlet

    I've run into something that is "very" frustrating with the new SQL Server 2012 PowerShell module.  When I Import the module, it breaks the "Test-Path" cmdlet when trying to test a UNC path to a directory.
    For example:  
    "Test-Path -path \\server\dirname" returns true as expected before the sqlps module is imported.  But after you import the SQL Server module "Import-Module 'sqlps' –DisableNameChecking" the same Test-Path
    now returns false.
    If I run the following in Windows PowerShell ISE I see the following results:
    Test-Path -path "\\server\directoryname"
    Import-Module 'sqlps' –DisableNameChecking
    Test-Path -path "\\server\directoryname"
    True
    False
    Anyone have any idea what's going on?
    UPDATE: after more testing, it looks like the problem happens with any cmdlet that references a UNC.  The New-Item has the same problem.  Before importing 'sqlps', New-Item is able to create a directory at the UNC path specified, but ater importing
    'sqlps', the New-Item fails.
    Thanks!

    Hi Mikea730,
    Sqlps.exe doesn't take advantage of a couple of these nice PowerShell V2 cmdlets without doing a bit of configuring in your environment. 
    Please refer to the following references to make some configuration in your server
    http://www.maxtblog.com/2010/11/denali-get-your-sqlpsv2-module-set-to-go/
    http://www.simple-talk.com/sql/database-administration/practical-powershell-for-sql-server-developers-and-dbas-%E2%80%93-part-1/
    http://sev17.com/2010/07/making-a-sqlps-module/
    Thanks,
    TechNet Subscriber Support
    If you are
    TechNet Subscription user and have any feedback on our support quality, please send your feedback
    here.
    Iric Wen
    TechNet Community Support

  • Pass login credentials into a test-path cmdlet

    Here is the scenario. I'm creating a SQL Server Job that will use Powershell to test if a session could be made to a remote server before creating one. I was able to successfully create a cmdlet that will test a path that connects to a remote shared server
    on the same domain. The remote server I'm trying to connect to is on a different domain so I need to pass along the login credentials. I'm stuck in finding the correct way to perform this. Is there a way to pass the login information without a prompt? Below
    is my test-path command I want to use.
    If(Test-Path -path \\IPADDRESS\Folder\subfolder)
        write-error "Remote connection test passed successfully"
    else {Write-Error "Could not connect successfully to "\\IPADDRESS\Folder\subfolder" -EA Stop}
    Also I was trying to use PSCredential to achieve this but was unsuccessful and received an error. Below is the powershell commands and error message.
    $SecurePassword = Read-Host -Prompt "Enter password" -AsSecureString
    $UserName = "DOMAIN\User"
    $Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword
    PS C:\Windows\system32>  If(Test-Path -path \\IPADDRESS\Folder\subfolder $Credentials)
    >>   {
    >>
    >>     write-error "Remote connection test passed successfully"
    >>
    >>
    >>   }
    >> else {Write-Error "Could not connect successfully to "\\IPADDRESS\Folder\subfolder" -EA
    Stop}
    >>
    Test-Path : A positional parameter cannot be found that accepts argument 'System.Management.Automation.PSCredential'.
    At line:1 char:14
    +  If(Test-Path <<<<  -path \\IPADDRESS\Folder\subfolder $Credentials)
        + CategoryInfo          : InvalidArgument: (:) [Test-Path], ParameterBindingException
        + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.TestPathCommand
    Thank you in advance

    Hi DBA_attack,
    Thanks for your posting.
    If there also occurred error after add the parameter -Credential, please also note: This parameter -Credential in test-path is not supported by any providers installed with Windows PowerShell.
    You can also try to use Invoke-Command with the credential who has the permission to access the tested file path.
    I hope this helps.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Copy, count files, test path, process indicator and System.IO.FileInfo

    I found this, sctipt, that I try to re-write.
    As it is, it creates sub folders in the targetfolder, which I found out how to stop it from, by deleting the "\" backslash sign in line 9.
    But what I also want is that subfolders if such should exist, also gets copied from $source to $target folder, as of now this doesn't happen. Reason why I chose to try to re-write the script is basically, I can read what it does and I like all the flashy
    Things like counting and that it shows the percentage of the processbar AND the processbar :).
    I just don't now how to re-write it proberly. By the way nothing should be re-named in the targetfolder every thing from sourcefolder should be "as is" in the sourcefolder.
    $SourceFolder = "C:\Color1\TRID"
    $targetFolder = “C:\Color2\TRID”
    $numFiles = (Get-ChildItem -Path $SourceFolder -Filter *.*).Count
    $i=0
    clear-host;
    Write-Host ‘This script will copy ‘ $numFiles ‘ files from ‘ $SourceFolder ‘ to ‘ $targetFolder
    Read-host -prompt ‘Press enter to start copying the files’
    Get-ChildItem -Path $SourceFolder -Filter *.* | %{
    [System.IO.FileInfo]$destination = (Join-Path -Path $targetFolder -ChildPath $_.Name.replace(“_”,“\”))
    if(!(Test-Path -Path $destination.Directory ))
    New-item -Path $destination.Directory.FullName -ItemType Directory
    [int]$percent = $i / $numFiles * 100
    copy-item -Path $_.FullName -Destination $Destination.FullName
    write-Progress -Activity “Copying … ($percent %)” -status $_ -PercentComplete $percent -verbose
    $i++
    Write-Host ‘Total number of files read from directory ‘$SourceFolder ‘ is ‘ $numFiles
    Write-Host ‘Total number of files that was copied to ‘$targetFolder ‘ is ‘ $i
    Read-host -prompt “Press enter to complete…”
    clear-host;

    @Jaap
    Yes I want to overwrite existing files, since backup is taken care of by another script.
    Now I encounter this error when trying to use your write-progress example:
    Get-ChildItem : A parameter cannot be found that matches parameter name 'Files'.
    At line:3 char:51
    + $Files = Get-ChildItem -LiteralPath $SourceFolder -Files
    +                                                  
    ~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
    cmdlet ForEach-Object at command pipeline position 1
    Supply values for the following parameters:
    Process[0]:
    Here is the script as I thought it should look like:
    $SourceFolder = "C:\Color1\TRID"
    $targetFolder = “C:\Color2”
    $Files = Get-ChildItem -LiteralPath $SourceFolder -Files
    $NumberofFiles = $Files.Count
    $Files | ForEach-Object -Begin {
    $FilesCopied = 0
    -progress{
    Write-Progress -Activity "Copying Files..." -PercentComplete [int](($FilesCopied/$NumberofFiles)*100) -CurrentOperation "$FilesCopied files copied out of total of $NumberofFiles files" -Status "Please wait."
    "$((Get-ChildItem -Recurse -File -LiteralPath $SourceFolder).Count) files will be copied to $targetfolder"
    Read-Host -Prompt 'Press Enter to Start Copying...'
    Copy-Item $SourceFolder -Recurse -Destination $targetFolder -Force -verbose
    $FilesCopied++
    # What is wrong now?

  • Test-Path -isValid alternatives: registry

    I am looking to validate a potential registry key or name, prior to working with it, so I can provide useful error reporting in a validation mode that does no actual work, it just validates data.
    I needed to do the same thing with file and folder paths, and was having real trouble so I punted to a Regular Expression, but I have not found a RegEx approach for validating a registry path. I have tried variations on Test-Path and Split-Path and everything
    returns true for a path like "HKCU\SOFTWARE\Autodesk\Revit\\2014", which should evaluate false.
    I already have code to validate hives, so I could just look for doubled backslashes, but that still leaves edge case errors unhanded. So, hoping that there is a way to validate a potential registry path that does not yet exist.
    And, I guess things like Revit\\2014 & Revit|2014 & Revit/2014 are technically all valid registry paths, but I would prefer to catch them.

    I agree.  Even in C/C# we always just used the path and checked the exception.   Test-Path is even more convenient.
    ¯\_(ツ)_/¯
    So, how would Test-Path be used here? Some more background is probably helpful first. So, my tool puts all sorts of data into an XML file, which is used in a cut n paste 'kit of parts'  way by customers to build up a sequence of tasks. Since many of
    those folks have never seen XML before (and never plan to see PowerShell, unfortunately) I have provided some "recipe" XML files that might look like this
    <Path>PATH TO... Setup.exe</Path>
    The user understands that PATH TO... must be replaced with a real path. However, things get missed, so I have implemented a Validation mode that goes through task by task and validates the data. And that's where I need to be able to catch something like
    "PATH TO... Setup.exe" and flag it as a data error in the Validation log, rather than waiting for a live test. In no small part because a live test can sometimes take hours, and finding out at the end that you just missed a cut n paste is really
    frustrating. Also, some folks want to change the reminders, so I want to catch anything that is invalid. And when I tested "NO DATA" and it came back as a valid path, Test-Path -isValid was no longer an option it seemed.
    And lastly, I do have a try/Catch in there, so if something sneaks by I'll get a meaningful error in the log. Meaningful to my users I mean, which a standard PowerShell error would not be. But, I am not sure what I would use to trigger the exception when
    I am not actually doing anything with the target, and it may not even exist, I just am trying to verify it is valid so I can proceed on.
    Thanks!

  • Test-path where a directory in the path is variable

    My company has a series of fax lines and associated file shares. Faxes are processed & then dropped off into these file shares. From that point a service runs about every 60 seconds to look for files in these directories to import into a database.
    If there is a problem with the import then the service moves the file to a "HOLD" folder & files remain there until human intervention.
    I am trying to create a script that will find the HOLD directory in each of these folders and look for the existence of files, then email a group of users alerting them if there are.
    So there are several things I'm trying to accomplish.
    1. Look for files in a path where a folder in the middle of the path is variable.
    2. Send and email that will inform the recipient that there are files in the HOLD folder(s) and tell them WHICH ones
    Here's what I am starting with but it isn't working as expected.  There are files in at least one of these.  I also thought to try using some kind of foreach loop but it's eluding me.  Probably because it's late in the day for me.
    $folder = get-content -Path "\\child.domain.com\netlogon\scripts\ps\numbers.txt"
    if(Test-Path -Path "\\Server\scan import\fax\$folder\Hold" -include *.pdf, *.tif, *.jpg) {write-host "Files exist at $folder"} Else {write-host "No files in the hold folders"}
    # When I wrote this script only God and I knew what I was doing. # Now, only God Knows!

    The numbers.txt includes a list of folder names, one per line. I did come up with the following and it's working, for my purposes, so I now need to figure out how to get the results into the body of a single email.
    $parent = "\\server\scan import\fax\"
    $folders = get-content -Path "\\child.domain.com\netlogon\scripts\ps\numbers.txt"
    Foreach ($folder in $folders)
    if(Test-Path -Path "$parent$folder\HOLD\*" -PathType leaf)
    write-host "Files exist at $parent$folder\Hold"
    Else
    write-host "$folder Clear"
    I'm really only using the Write-Host actions in place of the Send-MailMessage Cmdlet, at least I think that is the command I need.
    # When I wrote this script only God and I knew what I was doing. # Now, only God Knows!

  • Test-Path Registry Key

    Hi,
    I need to test a value for a particular registry key. If this value equals 12.5.1000.767, I need the script to exit. If this key  is missing, I need the script to perform a certain action. Can you provide some info, on how to script this.
    It seems we can use the test-patch cmdlet. 
    PS C:\> Test-Path "HKLM:\SOFTWARE\Wow6432Node\ComputerAssociates\Unicenter ITRM"
    True
    Thanks

    Hi David,
    Unicenter ITRM is the registry key and the value is 12.5.1000.767
    Thanks

  • [PowerShell] Ping multiple servers simultaneously with PowerShell: Test-ConnectionAsync (strange problems)

    I am hoping the author of the script "Ping multiple servers simultaneously with PowerShell: Test-ConnectionAsync" can help me.
    I found it at: https://gallery.technet.microsoft.com/scriptcenter/Multithreaded-PowerShell-0bc3f59b
    I am using the version dated: 5/8/2014
    I extraced the entire function from the .psm1 file for use in a script that continuously pings about 100 devices and sends an email when a device has failed three times in a row.  At some point, usually between 15 minutes and several hours, the script
    stops running.  If I break out of it <CTRL>-C, and run a "Get-Job" command, I can see that a job is "stuck" at the "Running" state.  I can even retrieve the data using "Receive-Job" and it looks fine.
     Here is a sample of the Get-Job after the program froze (I changed the Source and Destination to protect the names/IPs)...
    PS C:\Program Files\ServerScripts\DeviceMonitor> Get-Job
    Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
    145678 Job145678       WmiJob          Running       True            .                    Test-Connection
    PS C:\Program Files\ServerScripts\DeviceMonitor> Receive-Job 145678
    Source        Destination     IPV4Address      IPV6Address                              Bytes    Time(ms)
    SERVER1  XX.XXX.XXX.XX   XX.XXX.XXX.XX                                             32       5
    SERVER1  XX.XXX.XXX.XX   XX.XXX.XXX.XX                                             32       5
    SERVER1  XX.XXX.XXX.XX   XX.XXX.XXX.XX                                             32       5
    SERVER1  XX.XXX.XXX.XX   XX.XXX.XXX.XX                                             32       5
    PS C:\Program Files\ServerScripts\DeviceMonitor> Get-Job
    Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
    145678 Job145678       WmiJob          Running       False           .                    Test-Connection
    I tried added some additional output in the function to troubleshoot but I can't seem to find the root cause.  I would be happy if I could remove the "stuck" job after a certain amount time, even though this doesn't get to the root of the
    problem.
    Any assistance would be appreciated.  Even if you could point me in the right direction.
    Thank you.

    Hi,
    Questions for Gallery items should be asked on the QandA tab of the listing, as that is usually the fastest way to contact the script's author:
    https://gallery.technet.microsoft.com/scriptcenter/Multithreaded-PowerShell-0bc3f59b/view/Discussions#content
    Dave does frequent this forum, so you might get a response from him here directly.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Pass Command to Variable to Test-Path

    I'm passing a command to a vCenter in PowerCLI to backup VDS switches using a script I found on the internet. I want to do a test-path for the export location though to see if it backed up successfully. This would be okay if the portgroup name was static
    but it pulls it using a $_.name variable piped in from the get-vdswitch command. If I do a test-path for that variable outside of that line then it won't recognise it will it? Here's the code.
    foreach ($switch in $switches)
    # Backup each vNetwork Distributed Switch not including the port groups
    export-vdswitch $switch -Withoutportgroups -Description “Backup of $switch without port groups” -Destination “$full_path\$switch.without_portgroups.$date.zip“
    # Backup each vNetwork Distributed Switch including the port groups
    export-vdswitch $switch -Description “Backup of $switch with port groups” -Destination “$full_path\$switch.with_portgroups.$date.zip“
    # Backup each port group individually
    get-vdswitch $switch | Get-VDPortgroup | foreach { export-vdportgroup -vdportgroup $_ -Description “Backup of port group $($_.name)” -destination “$full_path\$($_.name).portgroup.$date.zip“
    To clarify, entire code works but I need to test that they backed up. The first two lines (export-vdswitch) will be okay because $full_path, $switch and $date are declared outside of that loop. So the problem comes doing a test-path on the location of the
    final command (probably could've said that briefer). Although retrieving the export path in a concise fashion would be beneficial.
    Thanks in advance

    Ho to clear things up? If I want to have it export to a variable called $exportedfile I can't pipe it out at the end like this for example:
    get-vdswitch $switch | Get-VDPortgroup | foreach { export-vdportgroup -vdportgroup $_ -Description “Backup of port group $($_.name)” -destination “$full_path\$($_.name).portgroup.$date.zip“ | $exportedfile
    If I try that it tells me that expressions are only allowed as the first element of a pipeline so how would I test-path against the output?

  • Powershell Test-SPContentDatabase -ShowLocation GUID located, how do i find the culprits in sp2010

    Hi All,
    i'm sure this is a simple one, but I dont know it, im running the below command while testing sp2010 database in 2013 and get a few errors so have found i need to run the showlocation parameter to find where the issues are
    after running the Powershell command to get the GUID: Test-SPContentDatabase -ShowLocation
    How do i find which web(s) are causing the problem, what am i supposed to do with the GUID given from the above command?

    Hi
    Thanks for the reply, but im sure there is a better way, surely, to get the sites that have the features installed in SP2010 that i dont have installed in SP2013
    so the cmd im running is: Test-SPContentDatabase -Name Database name -Webapplication
    http://name  -ShowLocation
    This gives me
    Message         : Database [Database Name] has reference(s) to a
                      missing feature: Id = [d45a2ae3-c85e-45c9-9408-35feda089a1d].
    Remedy          : The feature with Id d45a2ae3-c85e-45c9-9408-35feda089a1d is
                      referenced in the database [], but is
                      not installed on the current farm. The missing feature may
                      cause upgrade to fail. Please install any solution which
                      contains the feature and restart upgrade if necessary.
    Locations       : {1afdf415-6578-4df5-8441-asd0ebfddada,
                      1afdf415-6578-4df5-8441-asd0ebfddada,
                      1afdf415-6578-4df5-8441-asd0ebfddada
    So how do i find out what the location above represents please, or what feature i need to install in SP2013?
    Thanks

  • PowerShell Test-connection and Active Directory Input

    I am just learning powershell, and I"m working to write a script that pulls computer names from AD and puts them into a Test-connection cmdlet to determine if its valid.
    clear-host
    import-module activedirectory
    $workstations = Get-ADComputer -Filter '*' -SearchBase "OU=CMSD,OU=Windows XP,OU=Workstations,DC=TECH,DC=LOCAL" | FT Name
    Foreach($w in $workstations)
    Test-Connection -ComputerName $w -Count 1
    when i run the script, i receive the following error for all entries:
    Test-Connection : Testing connection to computer 'Microsoft.PowerShell.Commands.Internal.Format.GroupEndData' failed: The requested name is valid, but no data of the requested type was found
    At line:6 char:24
    + Test-Connection <<<< -computername $w -Count 1
    + CategoryInfo : ResourceUnavailable: (Microsoft.Power...at.GroupEndData:String) [Test-Connection], PingException
    + FullyQualifiedErrorId : TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand
    I'm thinking that when the array is going into the Test-connection cmdlet, its adding string characters such as "name=computer" and not just the computer name.  I don't know how to edit strings in powershell.  
    any help is appreciated, thank you.

    When you return a computer you get multiple properties - DN, Name, SID, etc. You need to indicate what property you want using dotted notation.
    Test-Connection -ComputerName $w.Name -Count 1
    You can also only return the Name when you do your Get-ADComputer by piping it to Select-Object. If you do this option, your variable would not need the dotted notation (.Name). $w is all you would need, since it would only contain the Name property.
    Get-ADComputer -Filter * -SearchBase ... | select Name
    Oh my, I just realized you are piping this to Format-Table - get rid of that! Do one of the two options above and you should have this figured out. Doing a select may be the best option since you will be returning a smaller set of information.

  • Powershell Coding - Path and Variable Issues

    Hello, I am working with a powershell program to copy a file off of my flash drive and into the startup file of what ever user is logged onto that computer. 
    My code is
    powershell -command { }; $a=[Environment]::UserName ; $c='E:\Other\Programs\program2.bat' ; $b='C:/Users/$a/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup' ; copy $c $b ; start-sleep 30
     It just uses the $a instead of the variable name...  if I change it to " " it says that the path cannot be found a cmd or operable program. and it stops at Windows/Start 
    can anyone help me out with this?
    For anyone wondering why I am using powershell -command  instead of ISE is because I am running it from a .bat file because the execution policy is set to restricted AND CANNOT BE CHANGED.

    Try
    $b="\"C:/Users/$a/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup\"";
    You must use double quotes for Powershell to use the value of $a - See:
    https://technet.microsoft.com/en-us/library/hh847740.aspx
    and you need an extra set of quotes escaped with a backslash to cope with the space in "Start Menu" - See:
    http://www.tinyint.com/index.php/2011/04/20/escaping-quotes-in-powershell-exe-command-via-command-prompt/
    In future (or if this is not working for you) please direct questions about Powershell to this forum
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG

  • Powershell Test-connection Cmdlet

    Hi all,
    i want to test the connectivity between two specfic NIC ports. i executed the command :
    Test-Connection -ComputerName "10.15.0.1" -Source "10.15.250.53" -Quiet. but it has banged an error message:
    parameters set cannot be resolved using the specified named parameters.
    FYI- i executed the command without "-Quiet" and successfully executed.
    all i want to test the connectivity between the two specific NIC ports and i should get a boolean value. Please help me in this matter.
    Thanks,
    Hemanth

    You can't use -Quiet when also using -Source.  From the help (below), we can see that the -Source argument appears in the second parameter set, while the -Quiet doesn't.  The opposite applies to the third parameter set.
    SYNTAX
    Test-Connection [-ComputerName] <string[]> [-AsJob] [-Authentication <AuthenticationLevel> {Default | None | Connect | Call | Packet |
    PacketIntegrity | PacketPrivacy | Unchanged}] [-BufferSize <int>] [-Count <int>] [-Impersonation <ImpersonationLevel> {Default | Anonymous |
    Identify | Impersonate | Delegate}] [-ThrottleLimit <int>] [-TimeToLive <int>] [-Delay <int>] [<CommonParameters>]
    Test-Connection [-ComputerName] <string[]> [-Source] <string[]> [-AsJob] [-Authentication <AuthenticationLevel> {Default | None | Connect | Call
    | Packet | PacketIntegrity | PacketPrivacy | Unchanged}] [-BufferSize <int>] [-Count <int>] [-Credential <pscredential>] [-Impersonation
    <ImpersonationLevel> {Default | Anonymous | Identify | Impersonate | Delegate}] [-ThrottleLimit <int>] [-TimeToLive <int>] [-Delay <int>]
    [<CommonParameters>]
    Test-Connection [-ComputerName] <string[]> [-Authentication <AuthenticationLevel> {Default | None | Connect | Call | Packet | PacketIntegrity |
    PacketPrivacy | Unchanged}] [-BufferSize <int>] [-Count <int>] [-Impersonation <ImpersonationLevel> {Default | Anonymous | Identify |
    Impersonate | Delegate}] [-TimeToLive <int>] [-Delay <int>] [-Quiet] [<CommonParameters>]
    Grant Ward, a.k.a. Bigteddy

  • PowerShell Document Test Script

    Hi Everyone.
    I am in desperate need of some Powershell Test Script.
    I am trying to automate document composition testing, as in direct powershell to a directory containing the pdf document and data files. 
    I am able to get the data in raw form and then the data to be accessible on Powershell.
    I am trying to test if things are as they should be as according to a spec.
    CAN SOMEONE PLEASE HELP ME????
    i HAVE NEVER USED pOWERSHELL OR DONE ANYTHING LIKE THIS AND MY JOB DEPENDS ON IT.

    Hi CraigdelaRey,
    If you want to query all the .pdf files under directory d:\, please refer to the script below:
    Get-ChildItem d:\*.pdf -Recurse|select -ExpandProperty fullname
    To read the pdf file in Powershell, please refer to this script, which also need the itextsharp library from:
    http://sourceforge.net/projects/itextsharp/
    And the script below is for your reference:
    Add-Type -Path .\itextsharp.dll
    $reader = New-Object iTextSharp.text.pdf.pdfreader -ArgumentList "$pwd\test.pdf"
    for ($page = 1; $page -le $reader.NumberOfPages; $page++) {
    $lines = [char[]]$reader.GetPageContent($page) -join "" -split "`n"
    foreach ($line in $lines) {
    if ($line -match "^\[") {
    $line = $line -replace "\\([\S])", $matches[1]
    $line -replace "^\[\(|\)\]TJ$", "" -split "\)\-?\d+\.?\d*\(" -join ""
    Refer to:
    Using Powershell to Parse a PDF file
    If there is anything else regarding this script, please feel free to post back.
    Best Regards,
    Anna Wang

Maybe you are looking for