我们使用的外部系统需要导入excel模板。可以从Active Directory数据派生导入的数据。
我正在PowerShell 2.0中构建一键式解决方案,该模板将使用当前的Active Directory数据来构建此模板。
我正在使用的当前进程是Get-ADObject > select and do some reformating | Export-Csv
。
我要复制的模板有两个标题行。 Export-Csv
仅基于字段名称提供一个标头(我实际上使用Select-Object @{Label=,Expression=}
来自定义ADObject属性名称)。
如何添加另一个标题行?我可以在每个ADObject属性的开头添加一个条目吗?
Header 1 Entry1 Entry2 Entry3
到
Header 1 Header 2 Entry1 Entry2 Entry3
答案 0 :(得分:0)
也许只是重复到第二个标题?
Get-ADObject | Select-Object Header1,@{label='Header2';expression=$_.Header1}
或者如果需要在同一行中:
$Data = Get-ADObject | additional piping
$Data.Header1 += 'Header2'
$Data | Export-CSV
或者您正在尝试添加媒体资源
$Data = Get-ADObject | additional piping
[PSCustomObject]$NewData = $Data
$NewData | Add-Member -MemberType NoteProperty -Name 'MyProperty' -Value 'myvalue'
$NewData | Export-CSV
答案 1 :(得分:0)
因此,最终我得到了想要的东西,首先将AD对象转换为Custom对象,然后使用相同的字段(但将标头作为值)创建第二个Custom对象。将它们都放入一个数组中,写得很漂亮。
<?xml version='1.0' encoding='utf-8'?>
<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="@string/multi_app_name" android:name="com.synconset.MultiImageChooserActivity" android:theme="@style/Theme.AppCompat.Light" />
<activity android:name="com.soundcloud.android.crop.CropImageActivity" />
<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="de.appplant.cordova.emailcomposer.Provider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/emailcomposer_provider_paths" />
</provider>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
<meta-data android:name="com.facebook.sdk.ApplicationName" android:value="@string/fb_app_name" />
<activity android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/fb_app_name" android:name="com.facebook.FacebookActivity" />
<receiver android:enabled="true" android:name="nl.xservices.plugins.ShareChooserPendingIntent">
<intent-filter>
<action android:name="android.intent.action.SEND" />
</intent-filter>
</receiver>
<provider android:authorities="${applicationId}.sharing.provider" android:exported="false" android:grantUriPermissions="true" android:name="nl.xservices.plugins.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/sharing_paths" />
</provider>
<activity android:exported="true" android:name="com.adobe.phonegap.push.PushHandlerActivity" android:permission="${applicationId}.permission.PushHandlerActivity" />
<receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler" />
<receiver android:name="com.adobe.phonegap.push.PushDismissedHandler" />
<service android:name="com.adobe.phonegap.push.FCMService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="com.adobe.phonegap.push.PushInstanceIDListenerService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
</manifest>