2

Every now and then, my powershell script prints below out of blue. I rechecked many times and I've no function or script to print this. Could someone please help me if this is a expected behaviour of powershell?

PSPath            : Microsoft.PowerShell.Core\FileSystem::\\SOMEDIR\
PSParentPath      : Microsoft.PowerShell.Core\FileSystem::\\SOMEDIR\
PSChildName       : SOMEFILENAME
PSProvider        : Microsoft.PowerShell.Core\FileSystem
PSIsContainer     : True
Name              : SOMEFILENAME
Parent            : Archieve
Exists            : True
Root              : \\SOMEDIR
FullName          : \\SOMEDIR\
Extension         :
CreationTime      : 17/05/2013 4:05:15 PM
CreationTimeUtc   : 17/05/2013 6:05:15 AM
LastAccessTime    : 17/05/2013 4:05:15 PM
LastAccessTimeUtc : 17/05/2013 6:05:15 AM
LastWriteTime     : 17/05/2013 4:05:15 PM
LastWriteTimeUtc  : 17/05/2013 6:05:15 AM
Attributes        : Directory
BaseName          : SOMEFILENAME
Mode              : d----

Below is the suspected powershell snippet:

foreach ($file in Get-ChildItem $path*.* -Include *.csv){ 

        if (!(Test-Path $archieveFolder) )
        {
            #1. Create config archieve directory
            New-Item -Path $archieveFolder -Force -ItemType Directory
        }
}
8
  • No this is not expected. There must be something within your code that's prompting this to happen, it will be difficult to help you as I can't see your code, but try outputting debug messages at various points in your script to try to pin point the line that causing this prompt Commented May 17, 2013 at 7:16
  • When you try Get-Job is there anything returned? Also what's definition of prompt function? (Look at Get-Content function:\prompt) Commented May 17, 2013 at 7:46
  • Something like ` Get-Item .\somedir | FL *` can return this output. Commented May 17, 2013 at 9:35
  • Yep this is the line, but on what scenario does it return this Commented May 18, 2013 at 0:36
  • @Myagdi Add the rest of the code... the suspect is innocent and we have no evidence to charge him Commented May 20, 2013 at 12:28

1 Answer 1

6
+50

New-Item outputs the item it creates. If you don't want it, cast to [Void] or pipe it to Out-Null.

New-Item -Path $archieveFolder -Force -ItemType Directory | Out-Null
Sign up to request clarification or add additional context in comments.

1 Comment

@Myagdi Great, glad to help. It's good to accept the answer if you consider your question answered.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.