# Get file info,user info,path,file size

**URL:** <https://forums.powershell.org/t/get-file-info-user-info-path-file-size/1734>\
**Category:** PowerShell Help\
**Created:** [July 19, 2013, 6:59am UTC](https://forums.powershell.org/t/get-file-info-user-info-path-file-size/1734 "2013-07-19T06:59:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sainiaman](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@sainiaman](https://forums.powershell.org/u/sainiaman)\
**Post date:** [July 19, 2013, 6:59am UTC](https://forums.powershell.org/t/get-file-info-user-info-path-file-size/1734/1 "2013-07-19T06:59:13Z")

</div>

Can someone help me to create a power shell.my requirement is that files are posted on sftp and under different folders like folder a, folder b and so on.files would be already there posted in the folders.file names would be same according to different folders.like if folder is a then a\_test.txt file would be posted and if folder is b then b\_test.txt file would be there.Now if there is a file under folders then i need to capture file size,path of the file,IP of computer who posted it and date posted.

I would need to run this power shell using a batch file on server.

&nbsp;

Can some one help me on this?

---

<div class="post-metadata">

**Author:** ![david-christian](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/david-christian/32/918_2.png) [@david-christian](https://forums.powershell.org/u/david-christian)\
**Post date:** [July 19, 2013, 8:37am UTC](https://forums.powershell.org/t/get-file-info-user-info-path-file-size/1734/2 "2013-07-19T08:37:32Z")

</div>

Sure we are more than happy to help.

What have you done so far?

Is there anything in particular giving you trouble?

---

<div class="post-metadata">

**Author:** ![sainiaman](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@sainiaman](https://forums.powershell.org/u/sainiaman)\
**Post date:** [July 21, 2013, 8:51am UTC](https://forums.powershell.org/t/get-file-info-user-info-path-file-size/1734/3 "2013-07-21T08:51:46Z")

</div>

Hi David,

I have created this script so far.Email function is working properly so i am not going to write it here.Here is what i have so far:

$AlertDetails = @(  
@{

Filepath = "D:\File\A\Folder";  
FileName=get-childitem Filepath -recurse | where {$_.extension -eq “.dat”} | Format-Table Name  
Fileuploadpath="\A\Folder"  
extension= “\*.dat”  
sourceIP=Get-WmiObject Win32\_NetworkAdapterConfiguration | Select IPAddress | Where-Object {$_.IPaddress}  
curretDate = (Get-Date).ToString(“yyyy-MM-dd HH:MM:ss”)  
},  
@{

Filepath = "D:\File\B\Folder";  
FileName=get-childitem Filepath -recurse | where {$_.extension -eq “.dat”} | Format-Table Name  
Fileuploadpath="\B\Folder"  
extension= “\*.dat”  
sourceIP=Get-WmiObject Win32\_NetworkAdapterConfiguration | Select IPAddress | Where-Object {$_.IPaddress}  
curretDate = (Get-Date).ToString(“yyyy-MM-dd HH:MM:ss”)  
}  
)  
$Subject = “Test”

$sendEmail = $false  
$FindFile = “”  
$unknownErrorSolution = “”  
$EmailContent = “”  
$Fileuploadinfo=“”  
$Ondate=“”  
$SourceIPinfo=“”  
$FileSizeinfo=“”  
$Userinfo=“”

foreach ($FileItem in $AlertDetails)  
{

# Set the file filter = File Path + file name

$fileFilter = $FileItem.Filepath + $FileItem.FileName

# Get files

$files = @(gci $FileItem.Filepath -Filter $fileFilter)

if ($files.Count -gt 0)  
{# If File exists  
$sendEmail = $true  
$Fileuploadinfo = $Fileuploadinfo + $FileItem.Filepath + $FileItem.FileName + “\<br /\>”  
$Ondate=$Ondate + $FileItem.curretDate + “\<br /\>”  
$SourceIPinfo=$SourceIPinfo + $FileItem.SourceIP + “\<br /\>”  
}  
else  
{# Unknown Error  
$sendEmail = $true  
$unknownErrorSolution = $unknownErrorSolution + “\<br /\>”  
}  
}

---

<div class="post-metadata">

**Author:** ![david-christian](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/david-christian/32/918_2.png) [@david-christian](https://forums.powershell.org/u/david-christian)\
**Post date:** [July 22, 2013, 8:11am UTC](https://forums.powershell.org/t/get-file-info-user-info-path-file-size/1734/4 "2013-07-22T08:11:07Z")

</div>

What is the error message you’re getting?

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:57pm UTC](https://forums.powershell.org/t/get-file-info-user-info-path-file-size/1734/5 "2024-05-16T20:57:42Z")

</div>


