Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Invoke-MachineDump
- {
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory=$True,
- ValueFromPipeline=$True,
- ValueFromPipelineByPropertyName=$True,
- HelpMessage='Please Enter a Machine Name')]
- [string]$machine
- )
- #Object for storing computer/logtype information
- $logRepo = "\\$server\$directoryPath..."
- $date = get-date -format MMddyyyy
- $logs = "\\OtherPC\C$\Logs"
- $machineDir = "$logRepo\$machine-$date"
- #Check for destination directory and create if not found
- if(!(Test-Path -Path $machineDir ))
- {
- try
- {
- New-Item -ItemType directory -Path $machineDir -ErrorAction Stop
- }
- catch
- {
- write-host "Directory already exists"
- }
- }
- ########################################################
- ### TODO Return object for point and shoot functionality
- ########################################################
- $returnObj = New-Object -TypeName psobject -Property @{
- computername = "$computer"
- windowsVersion = "$winVer"
- processList = "$procList"
- serviceList = "$serviceList"
- }
- $installLogs = Get-ChildItem "c:\logs" -filter "*.log" | select-object Name
- ###################################################
- ### Control Flow for Copying
- ###################################################
- foreach($file in $installLogs)
- {
- $f = $file.Name
- copy-item "$logs\$f" -destination $machineDir -recurse
- }
- ###################################################
- ### Get running processes/services from remote machine
- ###################################################
- get-process -computername $goPC | out-file "$machineDir\Processes.log"
- get-service -computername $goPC | where {$_.Status -eq "Running"} | out-file "$machineDir\Services.log"
- return $returnObj
- }
Add Comment
Please, Sign In to add comment