Example #1
0
        /// <summary>
        /// Add the 'UserName' NoteProperty to the Process object
        /// </summary>
        /// <param name="process"></param>
        /// <returns></returns>
        private static PSObject AddUserNameToProcess(Process process)
        {
            // Return null if we failed to get the owner information
            string userName = ClrFacade.RetrieveProcessUserName(process);

            PSObject       processAsPsobj = PSObject.AsPSObject(process);
            PSNoteProperty noteProperty   = new PSNoteProperty("UserName", userName);

            processAsPsobj.Properties.Add(noteProperty, true);
            processAsPsobj.TypeNames.Insert(0, TypeNameForProcessWithUserName);

            return(processAsPsobj);
        }