locked
problem package sccm RRS feed

  • Question

  • I have this script and when I implement it in sccm it does not copy the result to the shared path, previously created and with the necessary permissions. can you help me Thank you.

    Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Scope LocalMachine
    $serverName=hostname

    #If don't exist, create a folder with the server name
    $folder=hostname
    $folder='C:\'+$serverName
    $DestPath =  "\\.....\c$\Auditoria"

    if ((Test-Path $folder) -eq $False) {
        New-Item -Path $folder -ItemType Directory
    }

    #######################
    #GET BASIC SYSTEM INFO#
    #######################
    Get-WmiObject -class Win32_OperatingSystem | Select CSName,Caption,Version,BuildType, ServicePackMajorVersion,OSArchitecture,ProductType, OperatingSystemSKU,OSProductSuite,SuiteMask,OSType,Distributed,Status,Debug,InstallDate,LastBootUpTime,LocalDateTime,Locale,OSLanguage,CountryCode,NumberOfLicensedUsers,NumberOfUsers,EncryptionLevel,FreePhysicalMemory,FreeVirtualMemory,TotalVirtualMemorySize,TotalVisibleMemorySize,DataExecutionPrevention_SupportPolicy |
    Export-Csv -Encoding UTF8 -path $folder\osInfo.csv -NoTypeInformation

    Get-Wmiobject -Class ‘Win32_ComputerSystem’ -ComputerName $env:computername | Select Name,DNSHostName,Status,PartOfDomain,Domain,DomainRole,BootupState,ChassisBootupState,Manufacturer,Model,NumberOfLogicalProcessors,NumberOfProcessors,NetworkServerModeEnabled,HypervisorPresent,PCSystemType,PCSystemTypeEx,ThermalState,TotalPhysicalMemory,Workgroup|
    Export-Csv -Encoding UTF8 -path $folder\sysInfo.csv -NoTypeInformation


    #############################
    #GET INSTALLED SOFTWARE LIST#
    #############################
    Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |  Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
    Export-Csv -Encoding UTF8 -path $folder\installedSW.csv -NoTypeInformation


    ###############################
    #GET LIST OF INSTALLED PATCHES#
    ###############################

    #Cambiar a csv y dentro del dirctorio
    Get-HotFix | Select-Object CSName,HotFixID,Description,InstalledBy,InstalledOn,Caption,IPAddress,FixComments,Status |
    Export-Csv -Encoding UTF8 -path $folder\patches.csv -NoTypeInformation



    #########
    #GET GPO#
    #########
    gpresult /h $folder\GPO.html


    ################
    #GET USERS LIST#
    ################

    #Save a csv file with the local groups information
    Get-WmiObject -Class Win32_Group -Filter "LocalAccount='True'" | Select Domain, Name, Status, InstallDate |
    Export-Csv -Encoding UTF8 -path $folder\localGroups.csv -NoTypeInformation

    $groups = Get-WmiObject -Class Win32_Group -Filter "LocalAccount='True'" | Select -ExpandProperty Name

    #For each group, get the members information
    $groupMembers=@()
    foreach($group in $groups) {
        $groupMembers+=Get-WmiObject -Class Win32_GroupUser -Filter "GroupComponent=""Win32_Group.Domain='$serverName',Name='$group'""" -ComputerName $serverName | Select @{l="GroupName";e={$group}}, @{l="GroupMember";e={$_.partcomponent}}
    }
    $groupMembers | Export-Csv -Encoding UTF8 -path $folder\groupMembers.csv -NoTypeInformation

    #Get local users information
    Get-WmiObject -Class Win32_UserAccount -Filter  "LocalAccount='True'" | Select PSComputername, Domain, Name, FullName, Description, Status, Disabled, Lockout, AccountType, PasswordRequired, PasswordChangeable, PasswordExpires |
    Export-Csv -Encoding UTF8 -path $folder\users.csv -NoTypeInformation

    #Get extra information for local users
    $users=Get-WmiObject -Class Win32_UserAccount -Filter  "LocalAccount='True'" | Select -ExpandProperty Name
    foreach($user in $users){
        net user $user.split("\")[1] >> $folder\usersB.txt
    }


    Copy-item -Recurse -Path $folder -destination $DestPath 

    Tuesday, August 4, 2020 6:19 PM

All replies

  • A lot of what you are asking for is already within SCCM, why duplicate it? 

    Next the script is trying to write to a remote share, this will fail as the computer account doesn't have access to the remote share. 

    C$ is a bad share to use for this. 


    Garth Jones

    Blog: https://www.enhansoft.com/blog Old Blog: https://sccmug.ca/

    Twitter: @GarthMJ Book: System Center Configuration Manager Reporting Unleashed

    Tuesday, August 4, 2020 7:10 PM
  • Hi,


    Configuration Manager supplies many built-in reports covering many of the reporting tasks that you might want to do. You can also use the SQL statements in these reports to help you to write your own reports.
    Reports include but are not limited to hardware, operating systems, applications and software updates, etc.
    For more details, see:
    https://docs.microsoft.com/en-us/mem/configmgr/apps/understand/user-deployment-technical-reference


    This MECM Forum will be migrating to a new home on Microsoft Q&A<Link>, please refer to this sticky post<Link> for more details.



    Best regards,
    Larry

    "MECM" forum will be migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the "MECM" forum's new home on Microsoft Q&A!
    For more information, please refer to the sticky post.


    Wednesday, August 5, 2020 8:57 AM
  • Hi,


    The script is executed as the system or computer account on the targeted client(s). This account has limited network access. Any access to remote systems and locations by the script must be provisioned accordingly.

    Configuration Manager has an integrated ability to run PowerShell scripts. But Configuration Manager doesn't enable this optional feature by default. You must enable this feature before using it.

    For more details, see:
    https://docs.microsoft.com/en-us/mem/configmgr/apps/deploy-use/create-deploy-scripts

    This MECM Forum will be migrating to a new home on Microsoft Q&A<Link>, please refer to this sticky post<Link> for more details.

    Best regards,
    Larry


    "MECM" forum will be migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the "MECM" forum's new home on Microsoft Q&A!
    For more information, please refer to the sticky post.


    Wednesday, August 5, 2020 9:11 AM
  • Hi,


    How are things going? I just checked in to see if there are any updates. Please feel free to feedback and if the above reply is helpful, please kindly click “Mark as answer”. It would make the reply to the top and easier to be found for other people who has the similar question.

    If there is any other assistance we can provide, please feel free to let us know, we will do our best to help you.

    Thank you!


    Best regards,
    Larry

    "MECM" forum will be migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the "MECM" forum's new home on Microsoft Q&A!
    For more information, please refer to the sticky post.

    Monday, August 10, 2020 9:16 AM