Issue using Get-Child-Item

Have a function that will scan (grep) files in a folder with a certain extension.  For some reason, Get-Child-Item always returns empty / 0 files on my folder even though you can look at the folder and see files of the specified extension (*.config).
 Suspect either I am doing something wrong or permissions are somehow getting in the way.  How do you properly use Get-ChildItem
in this context?
function scan-Files
param(
[parameter(mandatory=$True)]
[string]$folder,
[parameter(mandatory=$True)]
[string]$filePattern,
[parameter(mandatory=$False)]
[bool]$recurse = $False
Write-Host "Folder = $folder"
Write-Host "FilePattern = $filePattern"
$files = Get-ChildItem -Include $filePattern -Path $folder
#always empty for some reason
if ($files)
Write-Host "File count = $($files.Length)"
}...#Invoke our function$folder = "C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\ReportServer\"
$filePattern = "*.config"         
#scan-Files -folder $folder -filePattern $filePattern -recurse:$true
scan-Files -folder $folder -filePattern $filePattern

The Gods of the computer demand it.  Without it you are only enumerating a folder item.  With it you are enumerating the contents of the folder.  Include only works on files that have been selected.
Example:
dir 'C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\ReportServer\*.txt' -include *.config
dir 'C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\ReportServer\*.c*' -include *.config
dir 'C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\ReportServer' -filter *.config
Try all to see how they work.
\_(ツ)_/

Similar Messages

  • And another issue - using : column like :item in a select in a cursor

    i use column like :item frequently but now i'm thinking that it slows down the select making it run much more slowly . any suggestions or documentation I might use ? Do you think that it would be better to use column = :item or not to use :item at all ? Thanks a lot !

    Like in Select is used as
    WHERE col1 LIKE 'aaa%'
    and disable the index on col1 (Sure exists Index-Function)
    as it's better writing
    WHERE account_name LIKE 'CAPITAL%'in comparison to
    WHERE SUBSTR(account_name,1,7) = 'CAPITAL'Sure is better if you can use col1 = :item but I don't know your goal.
    Regards

  • How to manage get-child item, then foreach child move the item some where

    Hi,
    I have a directory structure like the following:
    RootFolder
    -> SubFolder1
      * page1.txt
    * page2.txt
    * thumb1.jpg
    * thumb2.jpg
    -> SubFolder2
    * page1.txt
    * thumb1.jpg
    Now, what I want to achieve is like I should get a directory structure like the following:
    RootFolder 
    -> SubFolder1
    *SubFolder1txtFiles
    -page1.txt
    -page2.txt
    *SubFolder1jpgFiles
    -thumb1.jpg
    -thumb2.jpg
    -> SubFolder2
    *SubFolder2txtFiles
    -page1.txt
    *SubFolder2jpgFiles
    -thumb1.jpg
    These SubFolders may range from SubFolder1..n, same is the case for the number of files in them as well. Moreover I want the new child folder name affixed with the name of the Parent folder.
    Thanks in advance,
    -Aravind

    I'm sorry jrv. Consider me as a newbie to Powershell. Didn't get a complete clue how to solve this problem. That's why I didn't post the script. I've tried gci and move-item and rename-item cmdlets. But still not able to re-direct the categorized files to
    the corresponding subFolders.
    Just a sample what I tried out :
    Get-ChildItem E:\RootFolder\ -Recurse -Include *.txt |
    ForEach-Object{ $name = $_.Name
                New-Item -Path "E:\RootFolder\$name" -ItemType Directory
            Move-Item E:\DemoSessions\ComputerScience\Converted\$_\*.txt -Destination E:\RootFolder\$name\
    Thanks.

  • Issue using Get-DatabaseAvailabilyGroup -Status Exch 2010

    When trying to use this CMDLET (Get-DatabaseAvailabilyGroup -Status) on Exch 2010, I get a powershell error message:
    A server-side administrative operation has failed. The Microsoft Exchange Replication service may not be running on ser
    ver mail02.domain.local Specific RPC error message: Error 0x6d9 (There are no more endpoints available from t
    he endpoint mapper) from cli_GetDagNetworkConfig
        + CategoryInfo          : NotSpecified: (0:Int32) [Get-DatabaseAvailabilityGroup], ReplayServiceDownException
        + FullyQualifiedErrorId : 749A084,Microsoft.Exchange.Management.SystemConfigurationTasks.GetDatabaseAvailabilityGr
       oup
    What I don't understand is this server that it's referencing is the witness server to the DAG and SHOULDN'T have this service installed.  Has anyone run into this issue before, and if so, how did you fix it?  I have not tried rebuilding my DAG
    thus far.
    Thanks for any input.
    Thanks, Jeffrey - Infrastructure Administrator

    Hi,
    Have you checked Jared Van Leeuwen's suggestions? Is there any update?
    The Status parameter instructs the command to query Active Directory for additional information, and to include real-time status information in the output. Please add the DomainController parameter to specify a domain controller to retrieve data to check
    the result.
    If you have multiple DCs in your environment, please make sure there is no replication issues.
    If the issue persists, could you please use the ExBPA to check against your Exchange server health?
    Best regards,
    If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Belinda Ma
    TechNet Community Support

  • Remote Execution of a script with Get-Child Item cannot find path

    Hello!
    I have been tackling this problem for a few days now and I just can't find the answer.
    I want to execute scripts remotely in parallel so that each of remote machine will run the script with their own resources.
    Below is just the simple script in the local machine server1
    $Folder = \\server1\folder\subfolder
    GCI $folder
    It works fine it I call that through my client with this I am using in my client
    invoke-command -computername server -scriptblock {powershell.exe C:\filepath\script.ps1}
    But if I change the script inside to look at another machine server 2 and do
    $folder = \\server2\folder\subfolder
    It generates an error that it cannot find that path when trying to call GCI remotely. Note that it still works if the script is run locally.
    I did some research and I see about the double-hop using credssp but I just can't get it to work.
    Any help would be appreciated.

    Each system that you're remoting into (or calling Invoke-Command against) will need to have the WSManCredSSP server role enabled. You can do this through group policy, or you can do it on a per-machine basis. Here's what you would run on a computer if you
    want to only enable it on certain computers (you should be able to run this remotely):
    Enable-WSManCredSSP -Role Server
    The system that you're running everything from will be the CredSSP client. You'll need to run this from it:
    Enable-WSManCredSSP -Role Client -DelegateComputer *.yourdomain.com
    You'll need to change the 'yourdomain.com' to your domain name (or, you could simply put a * for the delegate computer, just be aware that this will allow your computer to pass credentials along to any computer when you tell a cmdlet to use CredSSP authentication).
    Now, to use Invoke-Command, do this:
    $cred = Get-Credential
    Invoke-Command -computername server.yourdomain.com -scriptblock {"Commands go here"} -Authentication CredSSP -Credential $cred
    Notice that the -ComputerName parameter is using a fully qualified domain name. If your -DelegateComputer parameter above used a domain name, you'll have to have the FQDN here.
    Let me know if that works for you. If you want more information, you can check out the Enable-WSManCredSSP and Disable-WSManCredSSP help topics.
    Hi Rohn,
    I tried doing your instruction but it gives me this error
    Connecting to remote server failed with the following error message : The WinRM client cannot process the request because the server name cannot be resolved. For more information, see the about_Remote_Troubleshooting Help topic.
    After enabling the client and server with the wsmancredssp
    Here is the command I executed that produced the error
    invoke-command -computername server01.domain01 -scriptblock {get-process} -authentication credssp -credential $cred.
    Thank you very much for all the help.

  • Query for BOM child items

    Dear Friends,
    This following query,if I will attach it at PO in Item Code with formatted search  , I get result as BOM child items as per project code, here project code is similar to item code.
    But my limitation is that my  item code is more than 8 character ,under accounting TAB BP project  ,project I can define it up to 8 character only.
    My requirement is that if I will put project name (which is 30 characteristic) as like as item code , shall I get child item list.
    If yes , suggest necessary changes in above query.
    Query :
    WITH RECUR ( CODE) AS
    SELECT ITT1.CODE FROM  ITT1 INNER JOIN OITT ON OITT.Code=ITT1.Father WHERE ITT1.Father=$[$157.1.1]
    UNION ALL
    SELECT ITT1.CODE
    FROM ITT1  INNER JOIN  OITT ON OITT.Code=ITT1.Father
    INNER JOIN RECUR ON   RECUR.CODE    =ITT1.Father
    SELECT CODE FROM RECUR inner join OITM on OITM.ItemCode=RECUR.CODE --and OITM.PlaningSys='M' and OITM.PrcrmntMtd='B'
    Thanxs & regards
    Mahesh.

    Dear Mahesh,
    I am not sure about your aim.
    You would like to put a formatted search in the project code field of the sales order in order to get the children of the itemcode of that line in the document. The child codes will become the name of the project.
    Your issue is the following:
    As the project code field in the sales order (field called: rdr1, project) is long 8 characters only and the sum of the children codes will be too long for this field.
    Am I correct?
    If I am not correct, can you please tell me step by step what you are trying to do?
    Thank you.
    Marcella Rivi
    SAP Business One Forums Team

  • Issue with child items of flex tree using QTP

    Hi,
    We are trying to automate Flex web application using QTP10.
    We are facing below issue with Flex tree when we try to automate a scenario of selecting a child item displayed in flex tree.
    Issue:
    On recording the step of selecting an item from Flex tree using QTP, the script displayed is .Select Index1. But when we replay it back no action is being performed.
    Also on object spy we are able to navigate only till flex tree and we are not able to spy child items of flex tree.On the web page the child items are displayed as radio buttons/checkboxes.
    Please provide a solution for me to this problem.
    Thanks

    Hi,
    You could perform a HTTP trace (using HTTP watch) and compare the OCI data in POST method for both users (the correct and incorrect ones).
    Perhaps there is some additional/missing information being passed from catalog to SRM.
    Kind regards,
    Ricardo

  • Report to get cumulative effort based on child items related to parent work item

    We have created a new work item type called 'Release' 
    Release -> Features -> PBI/Bugs -> Tasks/Test Case
    I have requirement to create many reports that has to filtered across the Release work item been created. We usually slice it by Area/Iteration but here the requirement is different.
    For ex: 
    Releases Overview report:
    Release name| Owner as AssignedTo| Status Indicator | Completed Work | Remaining Work | Open Impediments
    I can fetch all the release work items (Work Items with System_workItemType =Release) w.r.to team project for this report. But for other calculations :
    Compute Open Impediments
    Find all the child items belong to the parent 'Release work item'
    Pick Open Impediments (Work_Item_Count with System_workItemType=Impediment and State = Open) in that list.
    Is this possible by querying olap ?  Or we need to go for stored procedures for querying warehouse?
    please give a fair idea to start with and good resources for learning MDX.
    Thanks
    Divya

    Hi Divya,
    Thanks for your post.
    To get the Release work items and all linked Impediments, you can try to create the Work item and direct links query, under Filters for lined work items section, set Type of trees = Parent/Child, work item type = Impediments and State = Open. Please refer
    to the information in this document:https://msdn.microsoft.com/en-us/library/dd286705.aspx?f=255&MSPPError=-2147217396.
    For such a Release Overview report, you need create your custom report. For the MDX resource, please refer to this document:https://technet.microsoft.com/en-us/library/ms144785.aspx?f=255&MSPPError=-2147217396.
    Or contact SQL Server Reporting Service experts for the better response
    And you can also create the work item report using TFS API.    
    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.
    Click
    HERE to participate the survey.

  • 57F4 challan print - getting parent item no and po number for child item

    Hi ,
    In 57F4 challan, Subcontract components - i.e Child items are used for creating the challans.
    However while printing needs the parent item no with the purchase order number for that child item number.
    It is getting stored in RM07M structure.
    Any inputs / suggestions how to retrive parent item number and purchase order number for child item i.e for subcontract items?
    Thank you .
    Prasad.

    Thank you for the reply. I checked the table RSEG table for material document and PO details, however the RSEG gets populated when there is credit or debit entries.
    In this 57F4 challan there is no credit or debit enteries hence would not get in RSEG table.
    Appreciate your inputs for any other alternative.
    OR is there any table or Function Module to get the enteries of the struture of RM07M .

  • Issue with Parent child dashboards using SWFLoader component

    Hello Gurus,
    I am using Parent-child dashboards approach in our project.
    I have multiple child files embedded in Parent dashboard using the SWFLoader (directly passing the URL as SWFLoader value) to load child dashboards. All the child, parent swf's are saved in the same intranet folders.
    When I open the parent SWF, everything loads fine in the intranet.
    But for some users, when they open from the intranet, the child dashboard doesnt load up properly or size of the dashboard gets reduced to a small version. (Iam sure that it has nothing to do with the access/privileges)
    Any thoughts/ideas what could be causing an issue with child dashboard/resizing of the child dashboard.
    Please help!
    regards,
    S R

    Check whether the machine has compatible flash version in error specific machine and your machine.

  • HT1529 Upon startup my iMac has a popup that says: "talagent wants to use the local items keychain."  New to me--can't get anywhere.  How do I get out of this and get things up and running again?

    Upon startup my iMac (OSX Mavericks) has a popup (that I can't get rid of!) that says: "talagent wants to use the local items keychain."  I never set this up, don't want it, and want my iMac to start up with my desktop in place and ready to work.  I'd appreciate some help please.  How do I get rid of this?  Thanks.
    Larry

    I found this and it fixed my issue..
    I was suffering with this same problem, I followed these steps and everything returned to normality:
    1.- I opened KeyChain app and run the FirstAid (from the KeyChain app Menu)with my user Password (this do work) because the problem is not with your password. If there is any trouble with your keychain file this will fix it.
    2.- Opened Disk Aid and run Fix Persmissions just in case there was left some wrong file permissions during the upgrade.
    3.- Went back to the Key Chain App and Locked and Unlocked the Keychain using the Lock in the top left corner of the app. When asked for my password I simply typed my User password.
    After this everything worked fine. These are the steps that I followed but I really think that #3 did the trick here. You could try to do only #3 directly and it might fix your problem, but fixing the Keychain and fixing OS permissions is never a bad Idea.
    Good Luck friends.

  • Issue using the mp:Link item in a plug-in mpcui definition

    Hello,
    I'm developing an OEM plug-in and wanted to use the Link item - <mp:Link label="Click Me" click="{invokeActivity('myPage')}"/> - in my mpcui-defined UI.
    This actually works but it's conflicting with other content on the page. For example, if I define an InfoItem followed by the Link item, the link overlays the label of the InfoItem.
    Here's my code
    <mp:InfoItem label="My Label" value="Some text"/>
    <mp:Link label="Click Me" click="{invokeActivity('myPage')}"/>
    This results in a single line on the page with link label (Click Me) overlayed on top of the InfoItem label (My Label), with the InfoItem text (Some text) to the right.
    [overlayed My Label and Click Me]    Some text
    The mouse pointer turns into a finger pointer and I can click the garbled/overlayed text and it navigates to my page so it works; it's just messed up layout-wise. I don't have any positioning information in either element but normally, if I just use multiple InfoItem elements, they will be arranged vertically down the page. I was expecting the Link element to work the same way but it doesn't seem to for me.
    Has anyone seen this? know how to fix it?
    Thanks,
    Tom

    InfoItem tags can only be used as a child to the InfoDisplay tag.  And InfoDisplay only accepts InfoItem tags as children.  If you are trying to get a link into an InfoDisplay list, this can be done on the InfoItem tag:
                            <mp:InfoItem id="relatedHost" label="{getString('HOSTED_BY')}" value="{model.relatedHost}"
                                imageRenderer="{appModel.renderer('TARGET_TYPE')}"
                                imageDataSource="{model.relatedHostType}"
                                destination="{model.relatedHostLink}"  />
    destination can be an URL string or an Activity (which you have defined in your integration class).

  • I have been getting the wierdest, most ridiculous issues using PP 2014 here is a list:

    i have been getting the wierdest, most ridiculous issues using PP , 2014 here is a list:
    unsyncing single-source a/v when aplying effects.
    exporting the resynced clip to an even more out-of-sync clip
    freeze frame. when applying stabilizer, clip will just stall on a frame whereas before the effect, it didn't
    losing 2-3 hours of work due to auto-save failure. quitting premiere like normal but still having to force quit
    ramdom green frames that just suddenly appear
    constant crashing
    crashing without auto saving
    severe artifacting
    timeline, source, project thumbnails won't play
    toggle to previous/next edit point won't work
    significant, work-hidering issues in 90% of my project that collegues have never heard of
    pefferences will suddenly change. auto-save set to every 5 minutes and 100 versions will reset to default and audio scrubbing has just turned off
    no video, sound only during playback. freeze framing during playback
    pasting an item other than what was copied. copied a mask, pasted and mask of diferent size and shape
    inserting single frames between clips that i didn't add
    mixing unused video during transitions
    mixing unused video into masks.
    the above image is a mask that is being distorted by the image on the left below but it is only occuring in the mask.
    media pending sceen remains long after all content is loaded
    artifacting in the form of green pixel fields after exporting
    these issues are seriously hindering my ability to work. failed solutions i have run thru are:
    closing and reopening PP
    deleting render files and re-rendering
    replacing the distored clip with a  fresh clip
    rebuilding the mask
    restarting my computer
    PRAM and smc resets
    uninstalling and re-installing PP
    what is going on???

    Hi DV,
    Sorry you are having issues. FWIW, I also run a Mac and do not have these issues - however, I am still running OS X 10.8.5 on my personal machine.
    First of all, we need a lot more info: FAQ: What information should I provide when asking a question on this forum?
    deadvessel wrote:
    i have been getting the wierdest, most ridiculous issues using PP , 2014
    You say you are using "PP 2014," however, that is not precise enough. Which version of Premiere Pro CC 2014 are you using? 8.0.1, 8.1, or 8.2? Choose Premiere Pro > About Premiere Pro and look at the bottom of the dialog box. That will give you a precise version number.
    deadvessel wrote:
    Here is a list:
    Indeed, that's quite a list. My first suggestion is that you check out this article and perform the fixes there, if necessary: Premiere Pro CC, CC 2014, or 2014.1 freezing on startup or crashing while working (Mac OS X 10.9, and later) Are all the permissions set correctly?
    The other issue I see a lot is needlessly updating a project file in the middle of a project. The advice here is to avoid updating a project file to a new version of Premiere Pro as you work on it. Update before a new project is created.
    Try a test: update to Premiere Pro CC 2014.2 (8.2) and create a brand new project. Does it work better now?
    Thanks,
    Kevin

  • Goods issue using bapi  BAPI_GOODSMVT_CREATE getting error E M7

    HI  consultants,
    While  posting goods issue using bapi BAPI_GOODSMVT_CREATE . Running the batch job(zprogram) to post the goods issue . The goods issue is been posted by passing  goods receipt data's.
    while processing 3 goods receipt , 2 works fine one goods receipt getting  E M 7 300 NO ITEMS ARE TRANSFERED error.
    when i  processing one by one all the 3 goods receipt is working fine and process sucessfully. While processing in bulk ,i am getting this issue.
    If anybody faces this same problem or knows the solution .Please post the answer.
    The way i am passing the parameter to bapi given bellow.
        WA_GOODSMVT_CODE-GM_CODE = C_03.
    *--populate header data
        WA_GOODSMVT_HEADER-DOC_DATE   = WA_MKPF-BLDAT.
        WA_GOODSMVT_HEADER-PSTNG_DATE = WA_MKPF-BUDAT.
    *--populate item data      
    *-- call the bapi for posting goods issue
                 IT_GOODSMVT_ITEM-NETWORK     = WA_RESBP-AUFNR.
                IT_GOODSMVT_ITEM-RESERV_NO   = WA_RESBP-RSNUM.
                IT_GOODSMVT_ITEM-RES_ITEM    = WA_RESBP-RSPOS.
                IT_GOODSMVT_ITEM-ACTIVITY    = WA_RESBP-VORNR.
                IT_GOODSMVT_ITEM-MOVE_TYPE   = C_281.
                IT_GOODSMVT_ITEM-ENTRY_QNT   = WA_RESBP-NET.
    *--get the item details
                  IT_GOODSMVT_ITEM-MATERIAL   = WA_MSEG-MATNR.
                  IT_GOODSMVT_ITEM-PLANT      = WA_MSEG-WERKS.
                  IT_GOODSMVT_ITEM-STGE_LOC   = WA_MSEG-LGORT.
                  IT_GOODSMVT_ITEM-ENTRY_UOM  = WA_MSEG-ERFME.
                  CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
                    EXPORTING
                      INPUT  = WA_MSEG-PS_PSP_PNR
                    IMPORTING
                      OUTPUT = WA_PSPHI_TEMP.
                  IT_GOODSMVT_ITEM-WBS_ELEM   = WA_PSPHI_TEMP.
                  APPEND IT_GOODSMVT_ITEM.  
                CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
                  EXPORTING
                    GOODSMVT_HEADER  = WA_GOODSMVT_HEADER
                    GOODSMVT_CODE    = WA_GOODSMVT_CODE
                  IMPORTING
                    MATERIALDOCUMENT = WA_MATERIALDOCUMENT
                  TABLES
                    GOODSMVT_ITEM    = IT_GOODSMVT_ITEM
                    RETURN           = IT_RETURN.
    With Regards,
    Ambrose Mohandoss.

    Problem solved.

  • HT1766 I purchased an iPad air and chose a backup from my iPhone 5s.  The only issue is only 30 of my photos downloaded to my iPad and none of the music.  How can I get all items on the iPad?

    I purchased an iPad air and chose a backup from my iPhone 5s.  The only issue is only 30 of my photos downloaded to my iPad and none of the music.  How can I get all items on the iPad?

    you are using I tunes as the middle man for this back up, right?
    When you plug in the pad to i tunes, give it a unique name, like my pad.  I tune may be thinking it is talking to your phone.  It will keep track of what you what on each device.  Then plug your phone back in, and make sure your photos are uploaded to the computer - in i photo if you are using a mac, or in whatever photo program you are using on a windows device.  You also want to make sure you have uploaded to the computer all of your music.
    Once you get all that stuff there, plug the pad back in, and go through each of the tabs - selecting the music, photos etal that you want on the pad, then resync.

Maybe you are looking for