我正在搜索如何将所有值从$ scriptblock的输出获取到csv文件。它连接到Office 365并搜索所有租户,然后引发该租户的某些值。截至目前,该脚本将为多个租户提供输出。第一行获取有关不同租户的组织详细信息。
这就是我现在拥有的:
$ScriptBlock = {Get-OrganizationConfig}
# Establish a PowerShell session with Office 365. You'll be prompted for your Delegated Admin credentials
$Cred = Get-Credential
Connect-MsolService -Credential $Cred
$customers = Get-MsolPartnerContract -All
Write-Host "Found $($customers.Count) customers for this Partner."
foreach ($customer in $customers) {
$InitialDomain = Get-MsolDomain -TenantId $customer.TenantId | Where-Object {$_.IsInitial -eq $true}
Write-Host "Gettings Organization details for $($Customer.Name)"
$DelegatedOrgURL = "https://ps.outlook.com/powershell-liveid?DelegatedOrg=" + $InitialDomain.Name
Invoke-Command -ConnectionUri $DelegatedOrgURL -Credential $Cred -Authentication Basic -ConfigurationName Microsoft.Exchange -AllowRedirection -ScriptBlock $ScriptBlock -HideComputerName
}
这是现在的输出:
Gettings Organization details for ***
DefaultPublicFolderAgeLimit :
DefaultPublicFolderIssueWarningQuota : 1.7 GB (1,825,361,920 bytes)
DefaultPublicFolderProhibitPostQuota : 2 GB (2,147,483,648 bytes)
DefaultPublicFolderMaxItemSize : Unlimited
DefaultPublicFolderDeletedItemRetention : 14.00:00:00
DefaultPublicFolderMovedItemRetention : 14.00:00:00
PublicFoldersLockedForMigration : False
PublicFolderMigrationComplete : False
PublicFolderMailboxesLockedForNewConnections : False
PublicFolderMailboxesMigrationComplete : False
PublicFolderShowClientControl : False
PublicFoldersEnabled : Local
ActivityBasedAuthenticationTimeoutEnabled : True
ActivityBasedAuthenticationTimeoutInterval : 06:00:00
ActivityBasedAuthenticationTimeoutWithSingleSignOnEnabled : True
AppsForOfficeEnabled : True
AppsForOfficeCorpCatalogAppsCount : 0
PrivateCatalogAppsCount : 0
AVAuthenticationService :
CustomerFeedbackEnabled :
DistributionGroupDefaultOU :
DistributionGroupNameBlockedWordsList : {}
DistributionGroupNamingPolicy :
EwsAllowEntourage :
EwsAllowList :
EwsAllowMacOutlook :
EwsAllowOutlook :
EwsApplicationAccessPolicy :
EwsBlockList :
EwsEnabled :
IPListBlocked : {}
ElcProcessingDisabled : False
AutoExpandingArchiveEnabled : False
ExchangeNotificationEnabled : True
ExchangeNotificationRecipients : {}
HierarchicalAddressBookRoot :
ForwardSyncLiveIdBusinessInstance : False
OrganizationSummary : {}
ReadTrackingEnabled : False
SCLJunkThreshold : 4
SIPAccessService :
SIPSessionBorderController :
MaxConcurrentMigrations : Unlimited
MaxAddressBookPolicies :
MaxOfflineAddressBooks :
IsExcludedFromOnboardMigration : False
IsExcludedFromOffboardMigration : False
IsFfoMigrationInProgress : False
IsProcessEhaMigratedMessagesEnabled : False
TenantRelocationsAllowed : False
ACLableSyncedObjectEnabled : False
PreferredInternetCodePageForShiftJis : 0
RequiredCharsetCoverage : 100
ByteEncoderTypeFor7BitCharsets : 0
PublicComputersDetectionEnabled : False
RmsoSubscriptionStatus : Unknown
IntuneManagedStatus : False
AzurePremiumSubscriptionStatus : False
HybridConfigurationStatus : Unknown
ReleaseTrack :
CompassEnabled :
MapiHttpEnabled : False
RealTimeLogServiceEnabled : False
CustomerLockboxEnabled : False
OAuth2ClientProfileEnabled : False
PerTenantSwitchToESTSEnabled : False
LinkPreviewEnabled : True
OutlookPayEnabled : True
ConnectorsEnabled : True
ConnectorsActionableMessagesEnabled : True
SmtpActionableMessagesEnabled : True
OfficeGraphActivitySharingOrgOptout : False
UnblockUnsafeSenderPromptEnabled : True
AsyncSendEnabled : True
RefreshSessionEnabled : False
IsAgendaMailEnabled : True
NetworkThrottlingConfiguration :
BookingsEnabled : True
BookingsEnabledLastUpdateTime : 1-1-0001 00:00:00
BookingsPaymentsEnabled : False
BookingsSocialSharingRestricted : False
BookingsMembershipApprovalRequired : False
DisplayName : Accontrol
Heuristics : None
ResourceAddressLists : {\All Rooms}
IsMixedMode : True
PreviousAdminDisplayVersion : 0.10 (14.0.100.0)
IsAddressListPagingEnabled : True
ForeignForestFQDN : {}
ForeignForestOrgAdminUSGSid :
ForeignForestRecipientAdminUSGSid :
DefaultPublicFolderMaxItemSize : Unlimited
DefaultPublicFolderDeletedItemRetention : 30.00:00:00
DefaultPublicFolderMovedItemRetention : 7.00:00:00
PublicFoldersLockedForMigration : False
PublicFolderMigrationComplete : False
PublicFolderMailboxesLockedForNewConnections : False
PublicFolderMailboxesMigrationComplete : False
PublicFolderShowClientControl : False
PublicFoldersEnabled : Local
ActivityBasedAuthenticationTimeoutEnabled : True
ActivityBasedAuthenticationTimeoutInterval : 06:00:00
ActivityBasedAuthenticationTimeoutWithSingleSignOnEnabled : True
AppsForOfficeEnabled : True
AppsForOfficeCorpCatalogAppsCount : 0
PrivateCatalogAppsCount : 0
AVAuthenticationService :
CustomerFeedbackEnabled :
DistributionGroupDefaultOU :
DistributionGroupNameBlockedWordsList : {}
DistributionGroupNamingPolicy :
EwsAllowEntourage :
EwsAllowList :
EwsAllowMacOutlook :
EwsAllowOutlook :
EwsApplicationAccessPolicy :
EwsBlockList :
EwsEnabled :
IPListBlocked : {}
ElcProcessingDisabled : False
OrganizationSummary : {}
ReadTrackingEnabled : False
SCLJunkThreshold : 4
SIPAccessService :
SIPSessionBorderController :
MaxConcurrentMigrations : Unlimited
MaxAddressBookPolicies :
MaxOfflineAddressBooks :
IsExcludedFromOnboardMigration : False
IsExcludedFromOffboardMigration : False
IsFfoMigrationInProgress : False
IsProcessEhaMigratedMessagesEnabled : False
TenantRelocationsAllowed : False
ACLableSyncedObjectEnabled : False
PreferredInternetCodePageForShiftJis : 0
RequiredCharsetCoverage : 100
ByteEncoderTypeFor7BitCharsets : 0
PublicComputersDetectionEnabled : False
RmsoSubscriptionStatus : Unknown
IntuneManagedStatus : False
AzurePremiumSubscriptionStatus : False
HybridConfigurationStatus : Unknown
ReleaseTrack :
CompassEnabled :
MapiHttpEnabled : False
RealTimeLogServiceEnabled : False
CustomerLockboxEnabled : False
OAuth2ClientProfileEnabled : True
PerTenantSwitchToESTSEnabled : False
LinkPreviewEnabled : True
OutlookPayEnabled : True
ConnectorsEnabled : True
ConnectorsActionableMessagesEnabled : True
SmtpActionableMessagesEnabled : True
OfficeGraphActivitySharingOrgOptout : False
UnblockUnsafeSenderPromptEnabled : True
AsyncSendEnabled : True
RefreshSessionEnabled : False
IsAgendaMailEnabled : True
NetworkThrottlingConfiguration :
BookingsEnabled : True
BookingsEnabledLastUpdateTime : 1-1-0001 00:00:00
BookingsPaymentsEnabled : False
BookingsSocialSharingRestricted : False
BookingsMembershipApprovalRequired : False
LeanPopoutEnabled : False
OutlookMobileHelpShiftEnabled : True
OutlookMobileSingleAccountEnabled : False
ElevatedAccessControl :
AuditDisabled : False
WebPushNotificationsDisabled : False
WebSuggestedRepliesDisabled : False
ConnectorsEnabledForOutlook : True
ConnectorsEnabledForOutlookLastUpdateTime : 1-1-0001 00:00:00
ConnectorsEnabledForTeams : True
ConnectorsEnabledForTeamsLastUpdateTime : 1-1-0001 00:00:00
ConnectorsEnabledForSharepoint : True
ConnectorsEnabledForSharepointLastUpdateTime : 1-1-0001 00:00:00
Heuristics : None
ResourceAddressLists : {\All Rooms}
IsMixedMode : True
PreviousAdminDisplayVersion : 0.10 (14.0.100.0)
IsAddressListPagingEnabled : True
ForeignForestFQDN : {}
ForeignForestOrgAdminUSGSid :
ForeignForestRecipientAdminUSGSid :
ForeignForestViewOnlyAdminUSGSid :
MimeTypes : {}
IsLicensingEnforced : True
IsTenantAccessBlocked : False
IsTenantInGracePeriod : False
IsDehydrated : False
IsGuidPrefixedLegacyDnDisabled : False
IsMailboxForcedReplicationDisabled : False
RBACConfigurationVersion : 0.1
$ScriptBlock = {Get-OrganizationConfig}
# Establish a PowerShell session with Office 365. You'll be prompted for your Delegated Admin credentials
$Cred = Get-Credential
Connect-MsolService -Credential $Cred
$customers = Get-MsolPartnerContract -All
$Result =
foreach ($customer in $customers) {
$InitialDomain = Get-MsolDomain -TenantId $customer.TenantId | Where-Object {$_.IsInitial -eq $true}
$DelegatedOrgURL = "https://ps.outlook.com/powershell-liveid?DelegatedOrg=" + $InitialDomain.Name
Invoke-Command -ConnectionUri $DelegatedOrgURL -Credential $Cred -Authentication Basic -ConfigurationName Microsoft.Exchange -AllowRedirection -ScriptBlock $ScriptBlock -HideComputerName
}
$Result | Export-csv c:\sysadmin\export.csv -NoTypeInformation